views:

1638

answers:

2

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!

+3  A: 

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.

Jeromy Irvine
Thanks for the reply! Sounds good. Didn't know if .NET provided another attribute for this.
psuphish05
+2  A: 

I would create a enum for the DisplayMode attribute of your user control

Michael Kniskern