Reputation: 357
I create new form and add into panel in main form. When I click maximum in main form. Panel can dock fill in main form but form in panel can not resize.
add form into panel
frm2 = new frm2();
frm2.TopLevel = false;
frm2.AutoScroll = true;
// test
frm2.Dock = DockStyle.Fill;
splitmain.Panel2.Controls.Add(frm2);
frm2.Show();
Panel.SizeChanged
splitmain.Panel2.Dock = DockStyle.Fill;
splitmain.Panel2.Controls.Remove( frm2 );
frm2.Size = new Size(inPanel.Width, inPanel.Height);
frm2.Dock = DockStyle.Fill;
splitmain.Panel2.Controls.Add( frm2 );
splitmain.Panel2.Dock = DockStyle.Fill;
Picture
Thank You
Upvotes: 0
Views: 9149
Reputation: 3433
you should use Anchors on the Panel Too, Set them to RIGHT | LEFT | TOP | BOTTOM for a all direction resizing with the container..
if the pannel is nested in another panel, notice that the container should have the same Anchors too...
splitmain.Panel2.Anchor = Anchor.Left | Anchor.Right | Anchor.Top | Anchor.Bottom;
play with Anchors till you get the hang of it!
you can watch this movie to get little bit more familiar: http://www.youtube.com/watch?v=oO_zbWVklS8
Upvotes: 3