Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DataGridView Combobox Value

Status
Not open for further replies.

gharabed

Programmer
Sep 7, 2001
251
US
I seem to have a problem setting the value of a combobox in a datagridview. I am able to successfully bind a dataTable to my dataGridView and display all of the data in the gridView with the exception of the combobox. If I change the combobox column to a textBox then the data for that column is displayed. If I leave it a combobox then just blank values are displayed. Here is the code I use to populate the grid and also set the values in the combobox itself. Of course I comment out the combobox related code if I change the column to a textbox:

Code:
  Dim cBoxBuddy As New DataGridViewComboBoxColumn()
  Dim buddyTab As DataTable
  Dim participantTable As New DataTable()

...'Loads the DataTable objects with data
   ' The dataGridView name is "personnelDataGrid"

   ' Bind the dataTable to the dataGridView
  Me.personnelDataGrid.DataSource = participantTable

  'Load the combobox values in the datagridview
  cBoxBuddy = Me.personnelDataGrid.Columns("Buddy")
  cBoxBuddy.DataPropertyName = "buddyID"
  cBoxBuddy.DisplayMember = "buddyName"
  cBoxBuddy.ValueMember = "buddyID"
  cBoxBuddy.DataSource = buddyTab

What am I doing wrong in binding a value to the combobox? I have other comboboxes in the dataGridView which display data properly, however, these comboboxes have "hardcoded" values.

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top