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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:46:33+00:00 2026-05-28T14:46:33+00:00

I have a datagridview with three columns which is filled using Datareader. There is

  • 0

I have a datagridview with three columns which is filled using Datareader. There is a DatagridViewComboboxcolumn in the datagridView.

I want this DatagridViewComboboxcolumn should also be filled using datareader.

Please suggest how can i add items to DatagridViewComboboxcolumn using Datareader.
Below is the code that i have tried.

Here dr is SqlDatareader

Datagridview.Rows.Add(dr("Column1").ToString, dr("Column2"),dr("DatagridViewComboboxcolumn "))

But when i add this way im getting error on the DatagridViewComboboxcolumn Column.
Please Suggest

  • 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-28T14:46:35+00:00Added an answer on May 28, 2026 at 2:46 pm

    As previously mentioned, you cannot set the DataSource of a DataGridViewColumn to a DataReader (since this is a forward only, database connected object). What you can however do is fill a DataTable and the set the DataSource on the DataGridViewColumn to this DataTable. You will also need to set the DataPropertyName (this is the column name of the DataGridView’s datasource), ValueMemeber and DisplayMember. The example below uses the Adventureworks DB and populates a DataGridView with 4 columns (one of which is a combobox — ProductIdCombo). Simply create a form, drop a DataGridGridView control on it named DataGridView1 and run the following. The ProductId column demonstrates that the underlying column bound to the combo (ProductIdCombo column)is indeed updating the ProductId field in the dtProductsInventory DataTable.

            Dim dtProductInventory As New System.Data.DataTable
            Dim dtProducts As New System.Data.DataTable
    
            Using objSqlServer As New System.Data.SqlClient.SqlConnection("Server=LOCALHOST\SQLEXPRESS; Integrated Security=SSPI;Initial Catalog=AdventureWorks")
                objSqlServer.Open()
                Dim sqlCmd As New System.Data.SqlClient.SqlCommand("select * from production.ProductInventory", objSqlServer)
                dtProductInventory.Load(sqlCmd.ExecuteReader)
                sqlCmd.CommandText = "Select * from production.product"
                dtProducts.Load(sqlCmd.ExecuteReader)
            End Using
    
            DataGridView1.AutoGenerateColumns = False
            DataGridView1.DataSource = dtProductInventory
    
            Dim colProductIdCombo As New System.Windows.Forms.DataGridViewComboBoxColumn()
            colProductIdCombo.DataSource = dtProducts
            colProductIdCombo.DisplayMember = "Name"
            colProductIdCombo.ValueMember = "ProductId"
            colProductIdCombo.DataPropertyName = "ProductId"
            colProductIdCombo.HeaderText = "ProductIdCombo"
            DataGridView1.Columns.Add(colProductIdCombo)
    
            Dim colProductId As New System.Windows.Forms.DataGridViewTextBoxColumn()
            colProductId.DataPropertyName = "ProductId"
            colProductId.HeaderText = "ProductId"
            DataGridView1.Columns.Add(colProductId)
    
            Dim colShelf As New System.Windows.Forms.DataGridViewTextBoxColumn()
            colShelf.DataPropertyName = "Shelf"
            colShelf.HeaderText = "Shelf"
            DataGridView1.Columns.Add(colShelf)
    
            Dim colQuantity As New System.Windows.Forms.DataGridViewTextBoxColumn()
            colQuantity.DataPropertyName = "Quantity"
            colQuantity.HeaderText = "Quantity"
            DataGridView1.Columns.Add(colQuantity)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form created which an unbound datagridview that has three columns. Position,
I have a datagridview which I'm using for data entry. I've done this before
I have a datagridview where the users can select which subset of columns to
I have a DataGridView that I want to query using Linq (C# WinForm). I
I have a datagridview which im binding DataTable to. What I want do is
I have a datagridview with a bound combobox column which contains decimal value. There
i have one datagridview.in my datagridview is having four row and three columns.after enter
I have a datagridview on the form. and there are 4 columns in the
I have a DataGridView that has three read only columns in it and one
I have a datagridview with one DataGridViewCheckBoxColumn and some other TextBox Columns. I want

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.