gpt4 book ai didi

c# - Winform 自定义控件 : DesignMode doesn't return true whereas in Design Mode

转载 作者:IT王子 更新时间:2023-10-29 04:37:06 24 4
gpt4 key购买 nike

我在这里了解了 DesignMode How to refresh a winform custom control at design time after changing a property

但是当我在我的自定义控件的构造函数中使用它时,它永远不会返回 true,所以当我拖放我的自定义控件时它总是显示 max = 200,这是怎么回事?

if (this.DesignMode)
{
this.Min = 0;
this.Max = 100;
}
else
{
this.Min = 0;
this.Max = 200;
}

this.LabMin.Text = this.Min.ToString();
this.LabMax.Text = this.Max.ToString();

最佳答案

LicenseManager.UsageMode是为此而设计的。

事实上,这是检测控件是否处于设计模式的唯一可靠方法。它只在构造函数期间有效,但它可以很容易地存储在类的一个字段中以供以后引用。

即使容器控件处于设计模式,嵌套控件的 DesignMode 属性也将为 false。

关于c# - Winform 自定义控件 : DesignMode doesn't return true whereas in Design Mode,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4346361/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com