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 533863
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:33:09+00:00 2026-05-13T09:33:09+00:00

Anyone knows how to do this? I tried this , but it just populates

  • 0

Anyone knows how to do this?

I tried this, but it just populates this ComboBox which I already do.

What I need is a way to get the combobox updated whenever the enum property on my object changes:

DataObject.DataEnum

but also get the above Enum updated whenever I change the selected item in the combobox.

Is it possible to do this?

Normally I am used to do the binding this way:

this.TextBox.DataBindings.Add ( "Text", this.DataObject, "Name", false, DataSourceUpdateMode.OnPropertyChanged );

which works great.

  • 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-13T09:33:09+00:00Added an answer on May 13, 2026 at 9:33 am

    You can use a two-way binding on the SelectedItem property of the ComboBox. When adding values to the combo box, be sure to add the enum values and not just strings that match their display name.

    comboBox.Items.Add(ConsoleColor.Red);
    comboBox.Items.Add(ConsoleColor.Blue);
    // ... etc
    

    Now SelectedItem can be set or get as the enum instead of as a string.

    EDIT

    It sounds like maybe your object doesn’t raise property change notifications which Windows Forms requires to detect that changes to the underlying object need to be refreshed in the UI. Here is an article about how to do that.

    EDIT 2

    Here’s a code sample. I verified this works correctly.

    public partial class Form1 : Form {
    
        private Person p = new Person( );
    
        public Form1( ) {
    
            InitializeComponent( );
    
            comboBox1.DataSource = Enum.GetValues( typeof( Gender ) );
    
            textBox1.DataBindings.Add( "Text", p, "Name", false, DataSourceUpdateMode.OnPropertyChanged );
            comboBox1.DataBindings.Add( "SelectedItem", p, "Gender", false, DataSourceUpdateMode.OnPropertyChanged );
    
            label1.DataBindings.Add( "Text", p, "Name", false, DataSourceUpdateMode.Never );
            label2.DataBindings.Add( "Text", p, "Gender", false, DataSourceUpdateMode.Never );
    
        }
        private void Form1_Load( object sender, EventArgs e ) {
            // yeah, that's right i voted for him,
            // go ahead and downvote me
            p.Name = "John McCain";
            p.Gender = Gender.Male;
        }
        private void Form1_Click( object sender, EventArgs e ) {
            p.Name = "Sarah Palin";
            p.Gender = Gender.Female;
        }
    }
    
    public enum Gender {
        Male,
        Female
    }
    
    public class Person : INotifyPropertyChanged {
    
        private string name;
        private Gender gender;
    
        public string Name
        {
            get { return name; }
            set {
                name = value;
                PropertyChanged( this, new PropertyChangedEventArgs( "Name" ) );
            }
        }
    
        public Gender Gender {
            get { return gender; }
            set {
                gender = value;
                PropertyChanged( this, new PropertyChangedEventArgs( "Gender" ) );
            }
        }
    
        public event PropertyChangedEventHandler PropertyChanged = delegate {};
    
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was wondering if anyone knows an easy way to do this. I have
I've almost completed my project but just have this last thing which I've been
Is there anyone who knows this? I have been trying this for the last
I was wondering if anyone knows how this type of layout works http://500px.com/ Or
Does anyone knows why after I apply this algorithm in c++ to reduce the
Dose anyone knows why I have to use -use-network=false in my Flex Builder?!?!?! This
Per this question (see comments near the bottom), I was wondering if anyone knows
This is more of a hypothetical question. I am wondering if anyone knows if/how
I'm wondering if anyone knows of a way to export geometry/textures for a rigged,
I will just ask if anyone knows using python 2.7, how will i be

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.