Welcome to deBUG.to Community where you can ask questions and receive answers from Microsoft MVPs and other experts in our community.
0 like 0 dislike
1.3k views
in SharePoint Server by 39 47 54
Is it possible to create a custom property as a dropdown list in SharePoint Visual WebPart? I just can create a textbox custom property but I can't create a Combobox with selection as a custom property in Visual WebPart, How to do that?

1 Answer

1 like 0 dislike
by 159 198 381
selected by
 
Best answer

Dropdown list Custom Property in Visual WebPart

You can create a dropdown list as a custom property in Visual WebPart by defining your list as an enumeration as shown below

public enum customProperyList { Select,List1, List2, List3 };
public customProperyList  _list;

[WebBrowsable(true),
  WebDisplayName("My List"),
  WebDescription("Select from your list"),
  Personalizable(PersonalizationScope.Shared),
  System.ComponentModel.Category("Mail Settings"),
  DefaultValue("Select")
]

   public customProperyList  _List
      {
           get { return _list; }
           set { _list = value; }
        }

Output

combobox custom propery in visual webpart sharepoint 2019

See also, How to create a Custom Property in Visual WebPart?

If you don’t ask, the answer is always NO!
...