Winforms DesignMode Property是如何工作的?
我创建了一个用户控件,当您在设计器中看到它时,它看起来是空的。这对于程序员来说是个问题,因为他们不知道它在哪里。因此,在构造函数中,我添加了这个条件Winforms DesignMode Property是如何工作的?,winforms,Winforms,我创建了一个用户控件,当您在设计器中看到它时,它看起来是空的。这对于程序员来说是个问题,因为他们不知道它在哪里。因此,在构造函数中,我添加了这个条件 public MyControl() { InitializeComponent(); if (this.DesignMode == true) this.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; } 没有效果。如果我删除该条件,那么在
public MyControl()
{
InitializeComponent();
if (this.DesignMode == true)
this.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
}
没有效果。如果我删除该条件,那么在设计时和ofc运行时边界是可见的,这不是我的意图
我做错了什么?我也无法使用默认的
设计模式。。所以我在表格上这样做:
protected new bool DesignMode
{
get
{
return base.DesignMode || LicenseManager.UsageMode == LicenseUsageMode.Designtime;
}
}
这是一种黑客行为,但似乎起到了作用是的,这里有一个解释: