Hi,
I would like to force the invokation of the OnResize event handler of a control.
Currently I use (please forgive me) the following code:
Parent.SuspendLayout();
Parent.Height++;
Parent.Height--;
Parent.ResumeLayout();
Hi,
I would like to force the invokation of the OnResize event handler of a control.
Currently I use (please forgive me) the following code:
Parent.SuspendLayout();
Parent.Height++;
Parent.Height--;
Parent.ResumeLayout();
Thanks, but this is exactly what I would like to avoid (the need to add additional code at the parent control).
The case in question is a custom control which changes its height when an object is bound to it. I would like to trigger the contianer (parent) control's OnResize handler when this occurs. As there are multiple such controls, I would like to do it at the custom control's code (once) and not in the parent controls (many many...).
Short: It doesn't *have* to run. It's just extremely nice to have the parent automatically resize itself once its child control is resized.
Long: my control reflects the properties of its bound object. When I change the bound object, the size of this list may change. I want to resize the container control too. Some of the parent controls (which don't always contain such a "reflector" control, and vice versa) already have an automatic resizing code in the OnResize handler, and I would like to reuse it.
Sorry I wasn't clear:
Maybe the following pseudo-code can clarify:
class
ContainterPanel{
// some *special* super-panel functionality
}
class
ReflectorGadget{
private object boundObject;
public object BoundObject
{
get
{
boundObject = BoundObject;
/*
* build the UI of the ReflectorGadget here, resulting in resizing
* itself (the ReflectorGadget control) according to the number of
* the properties in the reflected (bound) object
*/
/*
* this is where I want to force the parent
* control's OnResize invocation
*/
}
}
}
In my main form, I have several ContainerPanel objects, some contain ReflectorGadget controls, some don't. Each of these panel objects has its own elaborate resizing code (which is too specific to reside in the class code).
When in my code I set reflectorGadgetXYZ,BoundObject = objectABC, I want to execute the aforementioned resizing code. This will fit the newly-resized reflectorGadgetXYZ in its parent ContainerPanel.
The thing is that the ContainerPanel resizing is specific to each control, while the invocation of BoundObject is in the class-level code.
I hope it's clearer now.