Reputation: 7907
If you have a user control with a field like public int number = 10;
can you make that value come up in the properties box when you use the designer in VS 2010 and C#?
Upvotes: 1
Views: 154
Reputation: 81675
You have to turn your variable into a property. Try adding Get Set and sometimes you have to add the proper attributes (referencing the System.ComponentModel class)
private int _Number = 10;
[DefaultValue(10)]
[Description("This is a number.")]
public int Number
{
get { return _Number; }
set { _Number = value; }
}
Note: The DefaultValue attribute is for setting the designer to bold or not. It doesn't actually set the default value.
Upvotes: 2
Reputation: 1604
using System.ComponentModel;
[Browsable(true)]
public bool SampleProperty { get; set; }
and if you want the property under a category
[Category("My Properties")]
public string MyCustomProperty{ get; set; }
Upvotes: 2