2010-02-19 77 views
1

我创建了一些控件,并且我定义了一些可以在设计时定义但只显示一个的属性。 另一个问题是,在显示的一个中,表单的文本框已显示,但我无法选择任何。通过自定义控件提供属性设计时间(.NET)

[Description("Blah Blah Blah"), 
    Category("Data"),    
    DefaultValueAttribute(typeof(TextBox), null), 
    Browsable(true)] 
    //Only show this one 
    public TextBox textBox 
    { 
     set { txt = value;} 
    } 


    [Description("Blah blah blah again"), 
    Category("Data"), 
    DefaultValueAttribute(typeof(string), null), 
    Browsable(true)] 
    public string Mensaje 
    { 
     set { sMensaje = value; } 
    } 

那么,什么是错我的代码

回答

6

你的属性丢失干将。

// Snip attributes 
public TextBox textBox 
{ 
    get { return txt; } 
    set { txt = value;} 
} 

// Snip attributes 
public string Mensaje 
{ 
    get { return sMensaje; } 
    set { sMensaje = value; } 
}