I have a TAdvStringGrid with 15 columns and up to 100 rows.
Resetting the column order takes a noticeable amount of time to complete this way:
grid.BeginUpdate;
grid.ResetColumnOrder;
grid.StringToColumnStates(ColumnStates);
grid.EndUpdate;
If I set the grid.Visible to false before and true after, the time is greatly reduced but the flash is annoying.
What else can I do instead? I thought the BeginUpdate and EndUpdate would have worked.
Was tested here with a default grid on the form
procedure TForm1.Button1Click(Sender: TObject);
var
t:dword;
begin
t := GetTickCount;
AdvStringGrid1.ResetColumnOrder;
caption := (GetTickCount - t).ToString;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
AdvStringGrid1.ColCount := 50;
AdvStringGrid1.RowCount := 5000;
AdvStringGrid1.LinearFill(false);
AdvStringGrid1.Options := AdvStringGrid1.Options + [goColMoving];
AdvStringGrid1.SetColumnOrder;
end;
and after moving the columns around, calling ResetColumnOrder takes between 100ms and 150ms.
I do have various events such as OnGetCellColor, etc used so maybe the redrawing caused by ResetColumnOrder moving and resiziing the columns is the issue.
Please provide a sample source project + steps with which we can reproduce this so we can investigate this.