Reputation: 5377
TMS's DBStringGrid component has a built in method which auto sizes row heights. I understand the property settings required for the method to work, and when called it works well.
I would like my grid's rows autosized anytime the grid is displayed, and I can't figure out where to place the method call. I thought the component's OnCustomCellDraw event would be the proper choice, but that just causes the flickering and memory usage associated with an endless loop (even when grid.doubleBuffering is set to true).
Where would you suggest I place the call to AutoSizeRows if I would like it to be called anytime the grid is being displayed?
UPDATE: Ken's answer is good but I'm also finding placing the call in the DataSource's OnDataChange event, whenever the DB kicks into Edit mode, may be as good for my purposes.
Upvotes: 1
Views: 307
Reputation: 125669
You can use the parent (containing) form's OnShow
event:
procedure TForm1.FormShow(Sender: TObject);
begin
// Make sure grid's data is available by opening the
// dataset first, and then call your AUtoSizeRows here.
end;
Upvotes: 2