开发者

How to use your custom c# property?

开发者 https://www.devze.com 2023-03-11 11:13 出处:网络
This sets a true/false property to design mode: private bool m_myProp; [Description(\"Set meatspin\"),Category(\"Values\"),DefaultValue(0),Browsable(true)]

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消