Search code examples
delphidevexpresstcxgrid

cxgrid : ApplyBestFit jerking


I run this query :

procedure TForm1.cxButton1Click(Sender: TObject);
begin
cxGrid1DBTableView1.ClearItems;
DataModule2.ACRQuery1.Close;
DataModule2.ACRQuery1.SQL.Clear;
DataModule2.ACRQuery1.SQL.Text := ADVMemo1.Lines.Text;
AdvMemo1.UpdateWrap();
try
 DataModule2.ACRQuery1.Open;
 except
   on E:Exception do
   begin
     MessageDlg('Napaka pri izvedbi : ' + E.ClassName,
                mtError, [mbOK], 0);
   end;
   end;
 cxGrid1DBTableView1.DataController.CreateAllItems;
 cxGrid1DBTableView1.ApplyBestFit();
end;

However when the query gets displayed in the grid I notice,for a split second,columns get displayed normally and then the best fit gets applied. Looks like some kind of a jerk.

Now, I don't know if this behavior is by design or I am applying the fit in the wrong place. What can I do to avoid this ?

This seems to improve things, thanks to Uli suggestion :

cxGrid1DBTableView1.DataController.CreateAllItems;
cxGrid1DBTableView1.BeginUpdate(); 
cxGrid1DBTableView1.ApplyBestFit();
cxGrid1DBTableView1.EndUpdate();

Solution

  • Try adding a BeginUpdate/EndUpdate pair.