0

I want to know how to add a property to my custom user control that has a drop down menu. Essentially I want to do the same this a when you select on of "None", "FixedSingle" or Fixed3D" when choosing the BorderStyle property in the Panel user control.

I know how to do it for one property:

[Description("Test text displayed in the textbox"),Category("Data")] 
public string Text {
  get { return myInnerTextBox.Text; }
  set { myInnerTextBox.Text = value; }
}

Now I want to be able to select a String from a predefined list of strings.

spatara
  • 893
  • 4
  • 15
  • 28

2 Answers2

0

This has worked in the past.

[Bindable(true),
 Category("Data"),
 DefaultValue("Test text displayed in textbox")]
Ross Bush
  • 14,648
  • 2
  • 32
  • 55
0

What you need is make your property of some custom enumeration type instead of string and provide the appropriate type converters for the designer. Making it of enum type restrict the possible values it can take, as in your example are "None", "FixedSingle" or Fixed3D" which belong to FormBorderStyleEnum.

See this similar question: Expose a collection of enums (flags) in Visual Studio designer

Community
  • 1
  • 1
Oscar
  • 13,594
  • 8
  • 47
  • 75