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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T04:14:31+00:00 2026-05-19T04:14:31+00:00

I recently asked this question on here and got the answer. However I’m now

  • 0

I recently asked this question on here and got the answer. However I’m now trying to apply the same logic on a DataGridView which is bound to a BindingList< T > of Curriculum objects. The Curriculum class has a property of type Year. I’m trying to use a ComboBoxColumn to update the reference the curriculum object has of years.

The comboboxcolumn is bound to a BindingList< T > of years, it errors if I set either the display member or the value member so I left them null. Doing this the datagridview successfully loads and displays the data correctly (I overrode the ToString method on the year class). However, if I choose another year object from the combobox, as soon as it end edits it throws and exception saying it can’t convert string to type year.

It looks like I need a TypeConverter to do it, but the problem is the combobox is displaying a descriptive value, which I can’t guarantee will be unique to that year object – so I have no way of getting a year object from a given string.

Has anyone got any experience in situations like these, it must be a pretty common thing to want to do but google has failed me on this occasion.

Marlon

  • 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-19T04:14:31+00:00Added an answer on May 19, 2026 at 4:14 am

    Same problem as here. Seems that object binding in a combobox column doesn’t work properly and you have to specify a ValueMember.

    For the particular project I am working on, I came to the conculsion that it was not worth implementing a custom type descriptor, so instead, I am using a fairly horrible hack:

    In the entity that I am binding to, I have the following:

    class TestEntity
    {
        public TestEntity BindingHack_ValueMember
        {
            get
            {
               return this;
            }
        }
        public string BindingHack_DisplayMember
        {
            get
            {
                return this.ToString();
            }
        }
    }
    

    And the databinding for the column looks like this:

    column.DataPropertyName = "Foo";
    column.DisplayMember = "BindingHack_DisplayMember";
    column.ValueMember = "BindingHack_ValueMember";
    

    A little ugly, perhaps, but it works …

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

Sidebar

Related Questions

I recently asked a question here, and someone provided this answer: private void button1_Click(object
I recently asked this question in the pyglet-users group, but got response, so I'm
OK, so this is leading on from another question I asked here recently. Basically,
I recently asked this question: Expose XML or Objects - thanks all for the
I recently asked this question and worked out that the reason a single email
This question is related to this other question I recently asked... cf.net exception and
I recently asked a question about what I called method calls. The answer referred
I was recently asked this question in an interview: How could you parse a
Hello everybody I've recently asked this question and I've given up with the 'replace
I recently asked this question , but after some of the responses and some

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.