[英]How to use your custom c# property?
This sets a true/false property to design mode:这会将 true/false 属性设置为设计模式:
private bool m_myProp;
[Description("Set meatspin"),Category("Values"),DefaultValue(0),Browsable(true)]
public bool Testprop
{
get
{
return m_myProp;
}
set
{
m_myProp = value;
this.AutoSize = value; // test if it also changes a standard property
}
}
Now I want it to work like this: When the user sets the property to true
a certain action will be taken.现在我希望它像这样工作:当用户将属性设置为
true
时,将执行某个操作。
How do I do that with a custom control and custom property?如何使用自定义控件和自定义属性来做到这一点?
How can I let the custom property behave like the basic property enabled = true
?如何让自定义属性表现得像基本属性
enabled = true
?
What exactly do you want to do?你到底想做什么? just use:
只需使用:
if(m_myProp) {
anywhere in the class.. if in the set block, after you've set it to value of course. class 中的任何位置.. 如果在设置块中,当然在您将其设置为值之后。
or或者
if(obj.Testprop) {
anywhere outside it.. Where obj is an instance of that class that has the Testprop property.它之外的任何地方.. 其中 obj 是具有 Testprop 属性的 class 的一个实例。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.