[英]Why this code is changing my main Form Background color after I open it?
This code is changing my Main Form background color after I open it.这段代码在我打开它后改变了我的主窗体背景颜色。
private void button1_Click(object sender, EventArgs e)
{
this.IsMdiContainer = true;
NewCustomer openform1 = new NewCustomer();
openform1.MdiParent = this;
openform1.Show();
}
Also is creating a border in the top of my borderless form.也在我的无边框表单的顶部创建一个边框。
When you set this.IsMdiContainer = true
WinForms is basically inserting an MdiClient
control into the form for you, and that's what you're seeing rather than the actual form itself.当您设置
this.IsMdiContainer = true
WinForms 基本上是在为您在表单中插入一个MdiClient
控件,这就是您所看到的,而不是实际的表单本身。 By default it has a grey background and a sort of sunken-in appearance that was quite common in early Windows UI.默认情况下,它具有灰色背景和一种在早期 Windows UI 中很常见的凹陷外观。
Changing the background is fairly trivial, as you can just set it on the MdiClient
itself.更改背景非常简单,因为您可以在
MdiClient
本身上进行设置。 You can find examples of that here:您可以在此处找到相关示例:
Change Background of an MDI Form 更改 MDI 表单的背景
Getting rid of the border is trickier because it's not directly exposed by the control itself, but you can find some approaches for that as well:摆脱边框比较棘手,因为它不是由控件本身直接暴露的,但您也可以找到一些方法:
How to remove 3d border (sunken) from MDIClient component in MDI parent form? 如何从 MDI 父窗体中的 MDIClient 组件中删除 3d 边框(下沉)?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.