I am authoring a new UserControl and I want to know when the container control resizes, and when does it set the width of the UserControl to be that of the container?
I though I might be able to set the Alignable property and set this to be AlignTop but this didn’t work when the container was a TabControl because it moved the control over the tabs.
I don’t believe that the AmbientChanged event fires on a parent resize?
Is there some way of detecting this?
There are no ambient changes when the parent size changes. As
Alignwon’t help, you’ll need to use the resize code of the form or tabstrib to resize the user control.Alternatively, you can align your user control in a picture box but that will still need to be resized by the container in code.
Here be dragons!
Another, far more fragile option is to get a reference to the container control and assign it to a
VBControlExtendervariable withWithEvents. This will then allow you to react to theResizeevent (if it has one) and callExtender.Move. Note that you must add code to the parent form to clear this on close otherwise you’ll have a circular reference and the form won’t shut down correctly.