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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T19:23:23+00:00 2026-05-15T19:23:23+00:00

I have a DataGridViewComboBoxColumn where I’m supposed to display different values than are selected,

  • 0

I have a DataGridViewComboBoxColumn where I’m supposed to display different values than are selected, much like what’s going on in this question:

DataGridViewComboBoxColumn name/value how?

In my case, I’m displaying lists of equipment which have an ID and a description. So my bound data class looks like this:

public class AURecord
{
    // member vars and constructors omitted for brevity
    public string ID { get { return _id; } }
    public string Description { get { return _description; } }
    public string FullDescription
    {
        get { return string.Format("{0} - {1}", _id, _description); }
    }
}

So I have the DisplayMember and ValueMember set up to be the FullDescription and the ID, respectively. So far so good.

The problem is, the requirements call for the FullDescription to be displayed in the drop list, but once a selection is made only the ID should appear in the text box (the description is to be displayed in a neighboring read-only column, and I have that working as well).

I’m hoping for a solution that only involves changing some properties on the DataGridViewComboBoxColumn object in my grid, though I fear the answer will be more along the lines of creating a DataGridViewComboBoxColumn subclass and doing a bunch of overloading (ugh)…

  • 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-15T19:23:24+00:00Added an answer on May 15, 2026 at 7:23 pm

    This seems to work:

    namespace WindowsFormsApplication2
    {
        using System;
        using System.Windows.Forms;
    
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
    
                _grid.CellFormatting += new DataGridViewCellFormattingEventHandler( OnGridCellFormatting );
    
                Column1.DisplayMember = "FullDescription";
                Column1.ValueMember = "ID";
                Column1.Items.Add( new AURecord( "1", "First Item" ) );
                Column1.Items.Add( new AURecord( "2", "Second Item" ) );
            }
    
            void OnGridCellFormatting( object sender, DataGridViewCellFormattingEventArgs e )
            {
                if ( ( e.ColumnIndex == Column1.Index ) && ( e.RowIndex >= 0 ) && ( null != e.Value ) )
                {
                    e.Value = _grid.Rows[ e.RowIndex ].Cells[ e.ColumnIndex ].Value;
                }
            }
        }
    
        public class AURecord
        {
            public AURecord( string id, string description )
            {
                this.ID = id;
                this.Description = description;
            }
            public string ID { get; private set; }
            public string Description { get; private set; }
            public string FullDescription
            {
                get { return string.Format( "{0} - {1}", this.ID, this.Description ); }
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

have a php code like this,going to convert it in to C#. function isValid($n){
(This question is narrower in scope than this question I asked earlier.) Say I
I have a datagridview with a DataGridViewComboboxColumn column with 3 values: Small, Medium, Large
I have a dataGridView control with a DataGridViewComboBoxColumn column, the question is Which event
I have DatagridViewComboBoxColumn bound to a datasource, i want to show First Name +
I have a DataGridView where one of the columns is a DataGridViewComboBoxColumn . When
have written this little class, which generates a UUID every time an object of
Have a procedure which looks like Procedure TestProc(TVar1, TVar2 : variant); Begin TVar1 :=
have a problem. At first look at this HTML <div id=map style=background-image: url(map.png); width:
I have this problem: I have a datagridview that reads the data from a

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.