Object binding a public enum property to a combobox

Posted on 2006-04-10
Last Modified: 2008-01-16
I'm trying to use object binding in a vs2005 c# app - which works fine in general. However, i have a situation where one of the public properties of a class is an enum, which i would like to use a combobox to display the available options. Unfortunately, the bound winforms control only displays the default (first entry) in the enum and none of the others.

Is there a way to have the combobox display all options - similar to the following: combobox.datasource = Enum.GetNames(typeof(PersonStatus)); -  with an existing object setting the list index to the correct value for that instance?

Class and enum definitions as follows:

public enum PersonStatus
     Active = 0,
     Inactive = 1,
     Deceased = 2

public class Person
     private string m_Firstname;
     private string m_Surname;
     private PersonStatus m_Status;

     public Person()

     public Firstname
          get { return m_Firstname; }
          set { m_Firstname = value; }

     public Surname
          get { return m_Surname; }
          set { m_Surname = value; }

     public Status
          get { return m_Status; }
          set { m_Status = value; }

Any insight would be greatly appreciated.
Question by:drabaecus
    LVL 13

    Accepted Solution

    Take a look at this and see if this adds any benefit.

    Author Comment

    Well, that wasn't exactly what i was after but it lead me to combine what the wizard provides with the manual setting of the datasource which appears to have done the trick.

    i.e. i used the wizard to create object binding to winforms controls, using a combo box for the enum property then in the form constuctor set the datasource of the combo box using: combobox.datasource = Enum.GetNames(typeof(PersonStatus));

    LVL 13

    Expert Comment

    nice.  take care.

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Join & Write a Comment

    Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
    This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    26 Experts available now in Live!

    Get 1:1 Help Now