Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WinForm UI components layer order

Tags:

When we add any UI or container in WinForms, the later added component comes over the earlier added components, we can say it is in a higher layer.

How to change that layer order or component order after adding components?

like image 790
Moon Avatar asked Aug 29 '09 10:08

Moon


People also ask

Is WinForms deprecated?

As we mentioned above, WinForms is still available but the status of “maintenance mode” likely means it has no long term future. As time passed by, especially in the last 5-10 years, new tools continued to mature and rise in popularity, and each one of them offered many powerful features.

How do I change a layer in Visual Studio?

To layer controls at design time In Visual Studio, select a control that you want to layer. On the Format menu, select Order, and then select Bring To Front or Send To Back.

Is Winform a framework?

Windows Forms is a UI framework for building Windows desktop apps. It provides one of the most productive ways to create desktop apps based on the visual designer provided in Visual Studio. Functionality such as drag-and-drop placement of visual controls makes it easy to build desktop apps.

What is Winform panel?

Windows Forms Panel controls are used to provide an identifiable grouping for other controls. Typically, you use panels to subdivide a form by function. The Panel control is similar to the GroupBox control; however, only the Panel control can have scroll bars, and only the GroupBox control displays a caption.


1 Answers

When you place more than one control in the same place,one will end up on top,and the other will end up underneath.Usually this is the result of a minor mistake,such as incorrectly using the anchoring and docking features to creare resizable form.In some cases,however,you might want to overlap control for a specific effect.

When control overlap,it's the z-index that determines which control ends up on top.Essentially,every control existy in its own distinct numbered layer.A control that has the z-index layer 1 will appear above a control in z-index layer 2 if they overlap.Usually,the z-index of a group of controls is determined by the order in which you add the controls,so that the last control you add is always in the topmost layer (with a z-index of 0).

However, you can change these options.

To determine or set the z-index of a control , you can use the GetChildIndex() and SetChildIndex() methods of the Controls Collection.Here's an example that moves a control to the third layer in the z-index.

Controls.SetChildIndex(ctrl, 2); 

Usually, you won't need this kind of find-grained control.Instead,you'll just want to drop a control to the back of the z-index (the bottom-most layer) or bring it to the top.You can accomplish this feature at design time by right clicking on a control and choosing Bring to Fron or Send to Back.You can also perform the same task programmatically using the Control.BringToFront() or Control.SendToBack() methods.

ctrl.BringToFront(); // This is equivalent to Controls.SetChildIndex(ctrl,0); 
like image 81
Myra Avatar answered Sep 21 '22 07:09

Myra