How can I add a combobox in control designer properties for a WinForms custom control?

I'm creating a custom control with a property that can take value from a set of strings like "Man, Woman". So in in control designer properties I want to show a combobox with these 2 choices.

Is there a standard way to do so ? If not what should I implement ?


The simple way to do that is to add an enum to your code that defines the possible choices for your property, then configure your custom control's property to accept a value of that type. The Properties Window will automatically display a combo box for this property with all of the possible values in your enum listed.

So, for example:

public enum Gender

public class MyCustomControl : UserControl
    public Gender UserGender { get; set; }

Need Your Help

Save canvas image into png image file from Java Servlet

java html5 servlets image-processing canvas

I have been trying to save a canvas image from my HTML page to an image file in Java Servlet. I need to send the image from HTML to Java Servlet through an Ajax request. Can someone please help me ...

How to stop Eclipse 3.4 losing reference to the JRE in projects

java eclipse eclipse-3.4 ganymede

Sometimes when using eclipse it loses references to the JRE.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.