In certain conditions, SwapColumns will not correctly swap columns of data correctly. If you don't always set a Cell to something, SwapColumns gets confused. If you run the following code with AddDashFlg as False, it will not swap correctly. After the swap, column 1 has the data of both column 1 and 4. If you set addDashFlg to True, it will work.
addDashFlg := False;
for c := 1 to TMSFMXGrid1.ColumnCount - 1 do
TMSFMXGrid1.Cells[c,0] := 'C' + IntToStr(c);
for r := 1 to TMSFMXGrid1.RowCount - 1 do
for c := 1 to TMSFMXGrid1.ColumnCount - 1 do
begin
if Odd(r) then
begin
if not Odd(c) then
TMSFMXGrid1.Cells[c,r] := IntToStr(c)
else
if addDashFlg then
TMSFMXGrid1.Cells[c,r] := '-';
end
else
if Odd(c) then
TMSFMXGrid1.Cells[c,r] := IntToStr(c)
else
if addDashFlg then
TMSFMXGrid1.Cells[c,r] := '-';
end;
{ Does not work with addDashFlg as False }
TMSFMXGrid1.SwapColumns(1,4);
TMSFMXGrid1.SwapColumns(2,3);
{ This works with addDashFlg True or False }
//TMSFMXGrid1.SwapColumns(2,4);
//TMSFMXGrid1.SwapColumns(1,3);
Hi,
We have investigated this here and have applied a fix for this issue, the next version will address this.