In dropped two Panels in Window1, one is docked top and the other is docked at the bottom, I added a new User Control and put a Toolbar docked on top. When I dropped the User Control in Window1 using the Designer and set Dock=Fill, it works OK. However, when I removed the User Control from the Designer and created an instance of the User Control at runtime, the Toolbar is covered by Panel. The code is:
UserControl1 uc = new UserControl1();
uc.Dock = DockStyle.Fill;
Docking is applied using the z-order of the controls so Fill will fill whatever space is left available by other docked controls. When you use Controls.Add() the new control is rendered first since the z-order is from further away coming toward the viewer. For the Fill to use the remaining space use uc.BringToFront() after adding it to the parent.
You can test the order of docking and how the different sides overlap in the designer using right-click -> SendToBack/BringToFront.
Please login first to submit.