When creating a complex user interface, or working with a multiple document interface (MDI) form, it is often desirable to layer both controls and child forms. To move and keep track of controls and windows within the context of a group, you manipulate their z-order. Z-order is the visual layering of controls on a form along the form's z-axis (depth). The window at the top of the z-order overlaps all other windows. All other windows overlap the window at the bottom of the z-order.
To layer controls programmatically
txtFirstName
, is underneath another control and you wish to have it on top, use the following code:
[Visual Basic] txtFirstName.BringtoFront [C#] txtFirstName.BringToFront();
It should also be noted that Win Forms supports control containment. Control containment involves placing a number of controls within a containing control, such as a number of RadioButton controls within a GroupBox control. You can then layer the controls within the containing control. Moving the group box moves the controls as well, as they are contained inside it.
Control Manipulation on Win Forms | Controls by Category | Anchoring Controls on Win Forms | Docking Controls on Win Forms | Positioning Controls on Win Forms | Resizing Controls on Win Forms | Setting the Tab Order on Win Forms | Setting the Text Displayed by a Control | Working with Individual Controls | Controls You can Use on Win Forms | Control Technologies and Where to Use Them | Win Form Controls by Function