I basically created 2 child controls and I want to set their width to be equal to the width of the parent composite control. The problem is when I do this using the parent.Size property, it doesn't work. It only works once when you add the control.
Am I supposed to override an event not a property? I thought the property change would be signaled with a resize, right?
EDIT:
Here is the code, property doesn't work, but the OnResize event worked.
Q2: Shouldn't OnResize EventArgs e give me the new size?
public partial class CollapsableCtrl : UserControl
{
public CollapsableCtrl ( )
{
this.ChildCtrl = new CustomCtrl ( );
this.Size = new Size ( 181, 82 );
this.Controls.Add ( this.ChildCtrl );
}
CustomCtrl ChildCtrl { get; set; }
public new Size Size
{
get { return base.Size; }
set
{
this.ChildCtrl.Size = value;
Invalidate ( );
}
}
protected override void OnResize ( EventArgs e )
{
base.OnResize ( e );
this.ChildCtrl.Size = this.Size;
}
}