DGV Issue - 2 datasets....1 set as combobox collection list?
Ok, here is what I have
Dataset A - This is the data displayed in every field of the DGV(all textboxes + 1 combobox)
Dataset B - This is populated from a different SQL server and table than DatasetA and needs to be the COLLECTION of my combobox in the DGV
I have the displayed items working fine, but I am striking out when trying to set my collection in the combobox to a different dataset. Any tips to help me out? I am at square one with this. I am not sure what property to change.
I have my data bound correctly to DataSetA. All i need now is to change the combobox collection datasource if possible.
[632 byte] By [
o9z] at [2007-11-20 10:52:40]

# 1 Re: DGV Issue - 2 datasets....1 set as combobox collection list?
have you tried like this...
ComboBox1.DataSource = theDataSet.Tables("<table name>")
ComboBox1.DisplayMember = "<column name>"
# 2 Re: DGV Issue - 2 datasets....1 set as combobox collection list?
You essentially treat the combo box column in the grid just like it was itself a ComboBox control. You would much as Thread1 has suggested where ComboBox1 would be your column, not an actual ComboBox. You also need to set the ValueMember property to the name of the column whose value should be pushed to the cell.
Here's an example. Let's say that you have two tables. The Parent table has columns ID and Name, while the Child table has columns ID, ParentID and Name. You would do something like this:parentBindingSource.DataSource = parentDataSet.Tables("Parent")
comboBoxColumn.ValueMember = "ID"
comboBoxColumn.DisplayMember = "Name"
comboBoxColumn.DataSource = parentBindingSource
childBindingSource.DataSource = childDataSet.Tables("Child")
childDataGridView.DataSource = childBindingSourceNote the use of BindingSource objects between the data source and the controls. Also notice the order in which properties are set. If you have added a DataSet to your form then all this can be done in the designer with no code.