Windows窗体,对象出现在其他项目的前面?

当我在我的表单中添加氪项时,它们会出现在其他项目的顶部,我怎样才能将它放在其他项目的后面?

假设您正在使用Winform设计器,您可以右键单击一个控件并从上下文菜单中选择“Bring to Front”或“Send to Back”以更改控件的“z-order”。

出现在其容器内的控制顺序由Z-Index控制。

在设计器中右键单击控件。 从上下文菜单中选择“Bring ro front”。

如果你按程序进行。 winforms环境中的所有控件都有两种方法:BringToFront()和SendToBack()。 您可以调用它来设置控件的z-index。

如果要明确指定Z-Index,可以使用此解决方法:

public static class ControlExtension { public static void SetControlZIndex(this Control ctrl, int z) { ctrl.Parent.Controls.SetChildIndex(ctrl, z); } } 

用法:

 button1.SetControlZIndex(10);