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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:01:32+00:00 2026-06-09T23:01:32+00:00

I have a question that I hope someone could help me with. My question

  • 0

I have a question that I hope someone could help me with. My question involves winforms and the datagridview in Visual Studio 2008. I want to bind my datagridview to a collection of business objects instead of a dataset. I would like to have comboboxes in the datagridview which get its value from one of the properties in the business object. Is this possible? Can someone please provide example code or provide a web page which describes how to do this. Any help would be appreciated.

Thanks,
Greg

  • 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-09T23:01:34+00:00Added an answer on June 9, 2026 at 11:01 pm

    Here is a simple data class:

    Public Class MyData
    
      Private _ID As Integer
      Private _ItemValue As String
    
      Public Sub New(ByVal id As Integer, ByVal itemValue As String)
        _ID = id
        _ItemValue = itemValue
      End Sub
    
      ReadOnly Property ID() As Integer
        Get
          Return _ID
        End Get
      End Property
    
      Public Property ItemValue() As String
        Get
          Return _ItemValue
        End Get
        Set(ByVal value As String)
          _ItemValue = value
        End Set
      End Property
    
    End Class
    

    Create a form and place a DataGridView control on it, add this code:

    Private myList As New List(Of String)
    Private myItems As New List(Of MyData)
    
    Protected Overrides Sub OnLoad(ByVal e As EventArgs)
      MyBase.OnLoad(e)
    
      myList.Add("First Item")
      myList.Add("Last Item")
    
      myItems.Add(New MyData(1, "Last Item"))
      myItems.Add(New MyData(2, "First Item"))
    
      DataGridView1.AutoGenerateColumns = False
      DataGridView1.Columns.Add(New DataGridViewTextBoxColumn() With _
                               {.HeaderText = "ID", _
                                .DataPropertyName = "ID"})
      DataGridView1.Columns.Add(New DataGridViewComboBoxColumn() With _
                               {.HeaderText = "ItemValue", _
                                .DataSource = myList, _
                                .DataPropertyName = "ItemValue"})
    
      DataGridView1.DataSource = myItems
    End Sub
    

    Since you want comboboxes in your grid, you have to set AutoGenerateColumns to false and create them yourself, mapping each column to the property in your class through the DataPropertyName property. For the combobox, you can set its own DataSource for the list of drop down items.

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

Sidebar

Related Questions

I have a question and I hope someone can help me out. What I
I have another beginner's question that hopefully someone can help with. I'm trying to
I have a curious question, I hope someone can help me. I am using
I hope someone could help me out. My original task: I want to write
I hope this question isn't too dumb. We have many websites internally that need
this my first question on here. I hope someone can help. It is to
Hello I have a question that could seem complicated. But I will try to
I was hoping you could help answer an Objective-C based question for me that
I have a few questions that I hope clarity and facts can be fed
I have a question that should be quick and easy for you guys to

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.