Hi All,
I am trying to create a table with one fixed column (i.e. FixedCols:=1) in position 0, one drop-down column in position 1, and several "data" columns after that. I would like the "Data" columns to be movable (i.e. goColMoving := true) but do not want the drop-down column to be moved from position 1.
I have tried to catch when column 1 is moved as such:
procedure TForm1.StringGrid1ColRowMoved(Sender: TObject; IsColumn: Boolean;
sIndex, tIndex: Integer);
begin
if (sIndex=1) or (tIndex=1) then
begin
//ShowMessage('sIndex: '+IntToStr(sIndex)+' tIndex: '+IntToStr(tIndex));
if not HasSwapped then
begin
HasSwapped:=true;
StringGrid1.MoveColRow(IsColumn,sIndex,tIndex);
end
else
HasSwapped:=false;
end;
end;
The StringGrid1.MoveColRow triggered the event again (causing an infinite loop) hence the requirement for the "HasSwapped" flag.
The above code does not work, I believe because the event is triggered before the columns are swapped.
Does anyone have any suggestions for me, or is this beyond the capability of s StringGrid?
Thanks!
Craig