I am using Visual Studio 2008 | .NET 3.5 | C#. I have created an user control that has the following property: DisplayMode. DisplayMode is meant to either display a series of text boxes or a single text box.
[Browsable(true),
Category("Appearance"),
DefaultValue(DISPLAY_MODE_FIELDS),
Description("Indicates whether to display the phone number as a single text box or separate fields.")]
public string DisplayMode
{
get { return mDisplayMode; }
set { mDisplayMode = value; }
}
Therefore, I want the options of the property to either be 'Fields' or 'Single'. I specified above I want to make this browsable in the designer, but how do I set those two values as options rather than knowing to specify 'Fields', 'Single', etc. in the future? Is there another attribute that I can decorate the property with to list these options out or do I need to create an enum (which works)?
Thanks in advance and please let me know if you need any other info!
The enum is the way to go. It will provide IntelliSense for the values in the Visual Studio HTML editor, and it will be more type-safe and easier to use in the code.
Just create an Enum
In your user control -
public enum OrientationOption
{
Horizontal,
Vertical
}
public OrientationOption Orientation { get; set; }
That's it ! this is how it will look like in your VS autocomplete
I would create a enum
for the DisplayMode
attribute of your user control
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With