回答

2

你必须把你的变量变成一个属性。尝试添加获取设置,有时你必须添加适当的属性(引用位于System.ComponentModel类)

private int _Number = 10; 

[DefaultValue(10)] 
[Description("This is a number.")] 
public int Number 
{ 
    get { return _Number; } 
    set { _Number = value; } 
} 

注:默认值属性是用于设置设计师大胆与否。它实际上并不是设置为的默认值。

+0

财产你只需要申请与(假)的可浏览属性,如果你想隐藏属性检查公共财产。 – Strillo

+0

@Strillo真的,我删除它。 – LarsTech

+0

隐藏像BorderStyle之类的默认属性怎么样? –

2

using System.ComponentModel;

[Browsable(true)] 
public bool SampleProperty { get; set; } 

,如果你想下一个类别

[Category("My Properties")] 
public string MyCustomProperty{ get; set; } 
相关问题