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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:55:40+00:00 2026-06-11T09:55:40+00:00

i have my class with 4 public int properties. What i’m trying to do

  • 0

i have my class with 4 public int properties. What i’m trying to do is to bind List to BindingSource as DataSource and that BindingSource to DataGridView. Everything works perfectly, now i’m trying to “translate” cells value to something else. For example i have:

List<MyClass> list = new List<MyClass>()
list.Add(new MyClass(1,2,3,4))
list.Add(new MyClass(0,2,3,4))

So in DataGridView it would look like this:

----------------
Row1 1|2|3|4
----------------
Row2 0|2|3|4
----------------

But what i’m trying to do is to be something like this:

----------------
Row1 "Dog"|2|3|4
----------------
Row2 "Cat"|2|3|4
----------------

As you see “0” value from my class is visible as “Cat” and “1” as “Dog” in DataGridView . I want it to be ComboBoxCell and to be working in two directions. Changing “Dog” to “Cat” should change value in the underlying List from “1” to “0”. What is the best, cleanest way to do it? Thanks for any help.

  • 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-11T09:55:42+00:00Added an answer on June 11, 2026 at 9:55 am

    Every DataGridView has a collection of column definitions. Within that list there are currently four textBoxColumns. That’s why you see

    ----------------
    Row1 1|2|3|4
    ----------------
    Row2 0|2|3|4
    ----------------
    

    You now have to change the column definition for your first column to a DataGridViewComboBoxColumn. After that you can set a dataSource for this column (eg: a new BindingList containing Dog, Cat aso) and bind your sourceColumn to DataPropertyName

    // short demo code, MUST BE ADAPTED
    dgvCOMBOBOXCOLUMN.DataSource = YOUR_CATS_DOGS_BS;
    dgvCOMBOBOXCOLUMN.DisplayMember = COLUMNNAME_OF_BS_TO_SHOW;
    dgvCOMBOBOXCOLUMN.Value = COLUMNNAME_OF_BS_WITH_ACCORDING_IDs;
    dgvCOMBOBOXCOLUMN.DataPropertyName = COLUMNNAME_OF_MYCLASS_TO_BIN;
    

    Of course you can make those settings within the VS designer, which is recommended!

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

Sidebar

Related Questions

Say I have a class with 2 properties class TestClass { public int propertyOne
I have a class that is inherited from List<T> and also has some properties,
I have a class containing two properties: public class player{ public player(String playerName,int points){
I have a class that has 2 properties and a constructor: public class Card
I have c# class i have different properties. public class Employee { public int
I have this simple class: public class MappingCollection<T> : List<T> { private int _declaredTotal
let say i have following class: class Shape { public int widht; public List<Point>
I have a class: public class LevelInfo { public int Id { get; set;
Say I have this class: public class Account { public int AccountID { get;
Suppose I have: public class foobar { public int lorem; public int ipsum; }

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.