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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:06:10+00:00 2026-06-15T14:06:10+00:00

I am working with C# 4.0 WinForms. I have a DataGridView which has all

  • 0

I am working with C# 4.0 WinForms. I have a DataGridView which has all of it’s columns set in the designer. The “Room” column is a DataGridViewComboBoxColumn column.

All of the cells show the correct information, including the Room Column. However, when I click on the DropDown for Room the items in the list show a quantity of rows which say System.Data.DataRowView instead of the actual value of the DisplayMember property.

My code looks like this:

DataTable dttRooms = GetDataTable();  //Returns rows with RoomID (GUID) and RoomType (string) columns
List<RoomType> roomType = new List<RoomType> { }; 
foreach (DataRow dr in dttRooms.Rows)
{
    roomType.Insert(roomType.Count, new RoomType { RoomID = Convert.ToString(dr["RoomID"]), RoomName = Convert.ToString(dr["RoomType"]) });
}

DataGridViewComboBoxColumn dgvc;
dgvc = (DataGridViewComboBoxColumn)dgvItems.Columns["Room"];
dgvc.HeaderText = "Room";
dgvc.DataPropertyName = "RoomID";
dgvc.DisplayMember = "RoomName";
dgvc.ValueMember = "RoomID";
dgvc.DataSource = roomType;

dgvItems.DataSource = dtForGridView; //dtForGridView contains a RoomID column with the GUID of the corresponding room.

I have defined a RoomType Class as below:

public class RoomType
{
    public string RoomID { get; set; }
    public string RoomName { get; set; }
}

If I change the room of an item in the database, it shows correctly on the GridView combobox column as expected.

I’ve set the DisplayMember and the ValueMember of the column. But when I pull the dropdown down to change the value, there’s the correct number of rows, but they seem to be ignoring their DisplayMember property. I’ve been trying for quite some time to figure out what I am doing wrong. I have spent hours and hours on SO looking at all similar questions and tried pretty much everything.

  • 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-06-15T14:06:11+00:00Added an answer on June 15, 2026 at 2:06 pm

    I changed the name of my Class and the RoomName property to RoomType:

    public class _RoomType
    {
        public string RoomID { get; set; }
        public string RoomType { get; set; }
    }
    

    I changed my code so that the names all match up:

    DataTable dttRooms = lda.RoomDetailsGet(SeriesID, JobID);
    List<_RoomType> roomType = new List<_RoomType> { };
    foreach (DataRow dr in dttRooms.Rows)
    {
        roomType.Insert(roomType.Count, new _RoomType { RoomID = Convert.ToString(dr["RoomID"]), RoomType = Convert.ToString(dr["RoomType"]) });
    }
    
    DataGridViewComboBoxColumn dgvc;
    dgvc = (DataGridViewComboBoxColumn)dgvItems.Columns["Room"];
    dgvc.HeaderText = "Room";
    dgvc.DataPropertyName = "RoomID";
    dgvc.ValueMember = "RoomID";
    dgvc.DisplayMember = "RoomType";
    dgvc.DataSource = roomType;
    
    dgvItems.DataSource = dtForGridView;
    

    Suddenly it’s working as expected. I’d still love to know why, but at least my problem is solved.

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

Sidebar

Related Questions

i am working on a DataGridView in C# 3.5, in winforms application. I have
I have a DataGridView control in a winforms app that I'm working on. The
we have WinForms app which stores data in SQL Server (2000, we are working
I am working with a WinForms DataGridView control. I have put this control in
I have a Winforms application which is working fine.. using a BackgroundWorkerThread to manage
I am working on a WinForms application and have to show the Application Icon(Notification
I have a winforms form in which I use a MediaElement. Everything is working
I'm working a WinForms based C# tool which has an attached MDF file based
I'm working on a WinForms application which also has some WPF elements. Until now
I have a datagridview on my WinForms app which shows a list of cases

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.