Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 203921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T17:25:18+00:00 2026-05-11T17:25:18+00:00

If I bind a WinForms ComboBox to an enum type’s values, i.e. combo1.DropDownStyle =

  • 0

If I bind a WinForms ComboBox to an enum type’s values, i.e.

combo1.DropDownStyle = ComboBoxStyle.DropDownList;
combo1.DataSource = Enum.GetValues(typeof(myEnumType));

Who knows how I could achieve the same result, while, in addition to entries matching each enum value, I can also have a blank entry representing no selection?

I cannot simply add a special value to the enum type because this must be flexible to deal with any enum type.

I’d appreciate your help.

Edit: I should make clear that I want to bind the actual enum values and not their names. If the actual enum values are bound, the ComboBox takes care of calling their ToString() to get the text to display.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T17:25:18+00:00Added an answer on May 11, 2026 at 5:25 pm

    (Please see my edit to the question where I clarified that I don’t want to bind to a collection of strings).

    After more fiddling, the following monstrosity seems to work. combo1.SelectedItem is of type object and will either be a DBNull or a (boxed?) enum value. Is this code advisable?

    combo1.DataSource = (new object[] { DBNull.Value }
                            .Concat(Enum.GetValues(refToAnEnumType)
                                .Cast<object>())).ToList()
    

    Edit: I see Adam and Andrew’s methods could easily be adapted to do the same thing. Thanks guys!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 111k
  • Answers 111k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Yes, you'll want to use something called a linked server:… May 11, 2026 at 9:43 pm
  • Editorial Team
    Editorial Team added an answer An alternative solution would be to create another report for… May 11, 2026 at 9:43 pm
  • Editorial Team
    Editorial Team added an answer You are facing two (IMHO) insurmountable challenges: Windows and Linux… May 11, 2026 at 9:43 pm

Related Questions

This is a bit of a strange one, but I've been struggling for a
I'm developing a WinForms application (.Net 3.5, no WPF) where I want to be
does anyone know if there is a simple way to bind a textblock to
I am attempting to rewrite my ForestPad application utilizing WPF for the presentation layer.
I have a Winform with a very basic premise: modify 2 string properties of

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.