Author: Tomas Rutkauskas
Does anyone know how to swap two columns in TStringGrid? If you try to exchange()
the two columns as if they are TStringLists all hell breaks out (... because they
aren't really TStringLists I guess?).
Answer:
I would use an intermediate, temporary string list. Let's say you want to exchange
columns 3 and 5:
1 var2 Temp: TStringList;
3 begin4 Temp := TStringList.Create;
5 Temp.Assign(MyGrid.Cols[3]);
6 MyGrid.Cols[3].Assign(MyGrid.Cols[5]);
7 MyGrid.Cols[5].Assign(Temp);
8 Temp.Free;
9 end;