Swap columns in a TStringGrid (Views: 2141)
Problem/Question/Abstract: 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: var Temp: TStringList; begin Temp := TStringList.Create; Temp.Assign(MyGrid.Cols[3]); MyGrid.Cols[3].Assign(MyGrid.Cols[5]); MyGrid.Cols[5].Assign(Temp); Temp.Free; end; |