This sets a true/false property to design mode:
private bool m_myProp;
[Description("Set meatspin"),Category("Values"),DefaultValue(0),Browsable(true)]
public开发者_StackOverflow中文版 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.
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
?
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.
or
if(obj.Testprop) {
anywhere outside it.. Where obj is an instance of that class that has the Testprop property.
精彩评论