Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I respond to a resize event in my custom grid control?

Tags:

delphi

I am new to Delphi and I'm building a custom control derived from TStringGrid. I need access to the OnResize event handler. How do I get access to it? TStringGrid's parent has a OnResize event

like image 912
Blue Avatar asked Dec 15 '22 14:12

Blue


1 Answers

Publish the OnResize event, which is protected by default in TControl.


In an own descendant, you should not use the event itself, but rather the method that triggers the event. Doing it that way will give the users of your component the opportunity to implement an own event handler.

Override the Resize method:

type
  TMyGrid = class(TStringGrid)
  protected
    procedure Resize; override;
  published
    property OnResize;
  end;

{ TMyGrid }

procedure TMyGrid.Resize;
begin
  // Here your code that has to be run before the OnResize event is to be fired
  inherited Resize; // < This fires the OnResize event
  // Here your code that has to be run after the OnResize event has fired
end;
like image 99
NGLN Avatar answered Mar 23 '23 14:03

NGLN