简体   繁体   English

如何使面板控件出现在所有其他控件的下面?

[英]How can I make a panel control appear underneath all other controls?

I have problems with a panel control in my WinForms application. 我的WinForms应用程序中的面板控件存在问题。 How to make it so its under everything else? 如何使其在其他所有条件下都如此? Right now the text is under the panel. 现在,文本在面板下方。

In the design view, select the panel and then click on the "Send to Back" option in the toolbar or on the context menu. 在设计视图中,选择面板,然后单击工具栏或上下文菜单中的“发送回”选项。

在工具栏上发送回

在上下文菜单上发送回

What this does is change the order the controls are added to the form. 这是更改控件添加到窗体的顺序。

If I have three controls, a CheckBox , Label and Button I see this code in the .designer.cs file: 如果我有三个控件,即CheckBoxLabelButton ,则在.designer.cs文件中看到以下代码:

        this.Controls.Add(this.checkBox1);
        this.Controls.Add(this.button1);
        this.Controls.Add(this.label1);

Sending the CheckBox to the back reorders the list so that it is added last. CheckBox发送到背面可对列表重新排序,以便最后添加列表。

        this.Controls.Add(this.button1);
        this.Controls.Add(this.label1);
        this.Controls.Add(this.checkBox1);

Therefore the controls in the ControlCollection must be drawn in reverse order as the ones at the end are the ones at the back and have to be drawn first so that they can be properly obscured by the ones in front. 因此, ControlCollection的控件必须以相反的顺序绘制,因为末尾的控件是后面的控件,必须首先绘制它们,以便它们可以被前面的控件正确遮盖。

尝试使用: textBox1.SendToBack();

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在窗体调整大小的面板中移动所有控件? - How can I move all the controls in a panel on form resize? 如何将ListView控件置于WPF中的其他控件之上 - How I can bring ListView control in top of other controls in WPF 如何使顶部停靠控件出现在*现有的顶部停靠控件下? - How do I make a top-docked control appear *under* the existing top-docked controls? 如何使用foreach循环删除面板中的所有控件? - How can I use a foreach loop to delete all of the control in a panel? 我怎样才能使窗体背景透明而不能使其他控件透明 - how can I make just the Form background transparent but not other controls 在下面的面板示例中如何使所有控件可见 - How to make all controls visible in following panel example 当窗口在.net中最大化时,如何调整控件(面板,网格)本身的大小 - how can i make resize to controls(Panel ,Grid) itself when window is maximize in .net 如何使用按钮侦听器(基本上)使 C# UI 删除面板控件? - How can I make a C# UI remove Panel Controls using a button listener (basically)? 如何在Panel(任何级别)内循环所有Checkbox控件? - How can I cycle ALL Checkbox Controls inside a Panel (at any levels)? 用户控制其他开发人员可以向其添加控件并“继承”我控件上所有控件的行为 - user control that other developers can add controls to it and “inherit” the behavior of all controls on my control
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM