I have written code that will resize a Control and all of its controls, but there’s a problem with the PropertyGrid. The user interface is a GroupBox that contains the TabControl tabContAll. In tabContAll is a TabPage that contains a PropertyGrid.
private void ResizeUI ()
{
ui.Location = new Point (this.ClientRectangle.Left, this.ClientRectangle.Top + menubar.Height);
ui.Size = new Size (this.ClientRectangle.Width, this.ClientRectangle.Height - menubar.Height);
ResizeControl (tabContAll, ui);
}
private void ResizeControl (Control control, Control parent)
{
control.Location = new Point (parent.ClientRectangle.Left, parent.ClientRectangle.Top);
control.Size = new Size (parent.ClientRectangle.Width, parent.ClientRectangle.Height);
foreach (Control child in control.Controls) {
ResizeControl (child, control);
}
}
This function is called when the form loads, and this is what it looks like compared to if I commented out the resizing in the loop so the PropertyGrid doesn’t get resized:


Furthermore when it is resized, the description doesn’t work. It just shows the name of the property.
I strongly recommend you to not write code for controls resizing unless you need a very very custom behaviour.
Set
Control.DockorControl.Anchorproperties instead, and leave the rest to them.For example, your case can be solved easily by setting the
Dockproperty toDockStyle.Fillfor both yourTabControlandPropertyGrid(and obviously removing the custom resizing methods).Here’s a complete MSDN Walkthrough for WinForms custom controls design:
http://msdn.microsoft.com/en-us/library/6hws6h2t.aspx