Hi,
It's an old post but anyway, I have experienced similar problems.
A set of my controls was not docking properly ( it was placed properly , but once I resized the form the controls stayed of the same size ( I was adding the controls at runtime). So , I actualy hadd to code a couple of methods to resize the whole control hierarchy.
private static void ResizeChildsInt(Control c,bool recursive) {
Rectangle r = c.DisplayRectangle;
foreach (Control item in c.Controls) {
if (item.Dock == DockStyle.Top) {
item.Top = r.Top;
item.Left = r.Left;
item.Width = r.Width;
if (item.Height > r.Height) {
item.Height = r.Height;
}
r = new Rectangle(r.X, r.Y + item.Height, r.Width, r.Height - item.Height);
} else if (item.Dock == DockStyle.Bottom) {
int bottom = r.Bottom - item.Height;
if (item.Height > r.Height) {
item.Height = r.Height;
}
item.Top = item.Height - r.Bottom;
item.Left = r.Left;
item.Width = r.Width;
r = new Rectangle(r.X, r.Y, r.Width, r.Height - item.Height);
} else if (item.Dock == DockStyle.Left) {
int width = item.Width;
if (width > r.Width) {
width = r.Width;
}
item.Top = r.Top;
item.Left = r.Left;
item.Height = r.Height;
item.Width = width;
r = new Rectangle(r.X + item.Width, r.Y, r.Width - item.Width, r.Height);
} else if (item.Dock == DockStyle.Right) {
int width = item.Width;
if (width > r.Width) {
width = r.Width;
}
item.Top = r.Top;
item.Left = r.Right - item.Width;
item.Height = r.Height;
item.Width = width;
r = new Rectangle(r.X, r.Y, r.Width - item.Width, r.Height);
}
}
foreach (Control item in c.Controls) {
if (item.Dock == DockStyle.Fill) {
item.Top = r.Top;
item.Left = r.Left;
item.Width = r.Width;
item.Height = r.Height;
}
}
if (recursive) {
foreach (Control item in c.Controls) {
if (item is UserControl == false) {
ResizeChildsInt(item, recursive);
}
}
}
}
public static void ResizeChilds(Control c) {
c.SuspendLayout();
ResizeChildsInt(c, true);
c.ResumeLayout();
}
Just call the static method ResizeChilds each time the control is resized.