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

  • Home
  • SEARCH
  • 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 1084941
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:37:33+00:00 2026-05-16T22:37:33+00:00

Is it possible to bind a ComboBox to a list of objects, but have

  • 0

Is it possible to bind a ComboBox to a list of objects, but have the selectedvalue property point to the object, not a property of the object?

I only ask because we have some Business Objects which have references to other objects – such as a ‘Year’ object. That year object may need to be switched out for another year object.


Only solution I can come up with is to have another class with a single property, in this case pointing to a year object. then bind the combobox to a List of these and set both the display and value members to the single property.

But doing that for any ‘lookups’ we have seems like a bit of a pain??

  • 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-16T22:37:33+00:00Added an answer on May 16, 2026 at 10:37 pm

    If you set the ValueMember to null the selected value will always be the object, not a property:

    {
        public class TestObject
        {
            public string Name { get; set; }
            public int Value { get; set; }
        }
        public partial class Form1 : Form
        {
            private System.Windows.Forms.ComboBox comboBox1;
    
            public Form1()
            {
                this.comboBox1 = new System.Windows.Forms.ComboBox();
                this.SuspendLayout();
                // 
                // comboBox1
                // 
                this.comboBox1.FormattingEnabled = true;
                this.comboBox1.Location = new System.Drawing.Point(23, 13);
                this.comboBox1.Name = "comboBox1";
                this.comboBox1.Size = new System.Drawing.Size(121, 21);
                this.comboBox1.TabIndex = 0;
                this.comboBox1.SelectedValueChanged += new System.EventHandler(this.comboBox1_SelectedValueChanged);
                // 
                // Form1
                // 
                this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
                this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
                this.ClientSize = new System.Drawing.Size(284, 262);
                this.Controls.Add(this.comboBox1);
                this.Name = "Form1";
                this.Text = "Form1";
                this.ResumeLayout(false);
    
                BindingList<TestObject> objects = new BindingList<TestObject>();
                for (int i = 0; i < 10; i++)
                {
                    objects.Add(new TestObject() { Name = "Object " + i.ToString(), Value = i });
                }
                comboBox1.ValueMember = null;
                comboBox1.DisplayMember = "Name";
                comboBox1.DataSource = objects;
            }
    
            private void comboBox1_SelectedValueChanged(object sender, EventArgs e)
            {
                if (comboBox1.SelectedValue != null)
                {
                    TestObject current = (TestObject)comboBox1.SelectedValue;
                    MessageBox.Show(current.Value.ToString());
                }
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a combobox that I bind to a list of objects with three
Trying to determine if it is possible to bind the SelectedValue of a ComboBox
I have a windows application project with a list of objects and combobox. How
Is it possible to bind to a property of a property? Here is what
Is it possible in WPF to bind a ListView (NOT a DataGrid) to a
Is it possible with only one bind to either keyup , keypress or keydown
Is it possible to add a dependency property to a ValueConverter and bind it
Is this possible to bind a strut-1 Bean property to multiple form elements?for example,
I've seen how to bind a ComboBox to a list that has columns like
I was just wondering if it would be possible to bind the list of

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.