Export (0) Print
Expand All
2 out of 2 rated this helpful - Rate this topic

How to: Layer Objects on Windows Forms

When you create a complex user interface, or work with a multiple document interface (MDI) form, you will often want to layer both controls and child forms to create more complex user interfaces (UI). 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.

NoteNote:

The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings or edition. To change your settings, choose Import and Export Settings on the Tools menu. For more information, see Visual Studio Settings.

To layer controls at design time

  1. Select a control that you want to layer.

  2. On the Format menu, point to Order, and then click Bring To Front or Send To Back.

To layer controls programmatically

  • Use the BringToFront and SendToBack methods to manipulate the z-order of the controls.

    For example, if a TextBox control, txtFirstName, is underneath another control and you want to have it on top, use the following code:

    txtFirstName.BringToFront()
    

    txtFirstName.BringToFront();
    

    txtFirstName.BringToFront();
    

    txtFirstName->BringToFront();
    
NoteNote:

Windows 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, because they are contained inside it.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.