Is there a way for a parent control to detect when a child control resizes? I'm considering writing a panel control that resizes as it's child controls resize (similar to the way a HTML DIV element will expand to fit it's contents).
To answer your actual question, I beleve that the AlignControls
method of your windowed control is called when a child control is resized or moved.
TControl
and TWinControl
have built-in support for handling auto-sizing for you. All you have to do is set the TControl.AutoSize
property to True. It is declared as protected
in TControl
, so you will have to promote it to public
or published
if you want your component users to set it. Otherwise, just set it in your component's contructor.
You can override the virtual CanAutoSize()
method if you want to customize how your parent control sizes itself relative to its children.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With