B
Brian Pelton
This is on .Net 2.0 in a WinForms application.
I have a DataGridView that is bound to a BindingSource. The
DataGridView has 3 columns. The first two are "normal" text columns and
the last is a combo box column.
Data binding is working fine for the first two columns. I am able to
edit values and persist them back to the bound object and ultimately
back to the database.
Data binding for the combo box column only shows the current value. I
cannot change it.
Here is the code for creating the combo box column:
DataGridViewComboBoxColumn dgvcQuantityUom =
new DataGridViewComboBoxColumn();
dgvcQuantityUom.Name = "QuantityUom";
dgvcQuantityUom.DataPropertyName = "QuantityUom";
dgvcQuantityUom.HeaderText = "Uom";
dgvcQuantityUom.DataSource = _uomList;
dgvcQuantityUom.DisplayMember = "UomName";
So, this column is bound to the property "QuantityUom". That property
is of the type "Uom" (Unit of Measure).
_uomList is an IList<Uom> of Uom objects. This is the drop down list
for the combo box.
---
When I do databinding for "normal" comob box controls outside of a
datagrid, I have a line that sets up the databinding:
myComboBox.DataBindings.Add("SelectedItem", myDataBindingSource,
"NameOfProperty");
But I don't see how I can get to the databindings for the DataGridView's
combo box.
Any ideas??
Brian
I have a DataGridView that is bound to a BindingSource. The
DataGridView has 3 columns. The first two are "normal" text columns and
the last is a combo box column.
Data binding is working fine for the first two columns. I am able to
edit values and persist them back to the bound object and ultimately
back to the database.
Data binding for the combo box column only shows the current value. I
cannot change it.
Here is the code for creating the combo box column:
DataGridViewComboBoxColumn dgvcQuantityUom =
new DataGridViewComboBoxColumn();
dgvcQuantityUom.Name = "QuantityUom";
dgvcQuantityUom.DataPropertyName = "QuantityUom";
dgvcQuantityUom.HeaderText = "Uom";
dgvcQuantityUom.DataSource = _uomList;
dgvcQuantityUom.DisplayMember = "UomName";
So, this column is bound to the property "QuantityUom". That property
is of the type "Uom" (Unit of Measure).
_uomList is an IList<Uom> of Uom objects. This is the drop down list
for the combo box.
---
When I do databinding for "normal" comob box controls outside of a
datagrid, I have a line that sets up the databinding:
myComboBox.DataBindings.Add("SelectedItem", myDataBindingSource,
"NameOfProperty");
But I don't see how I can get to the databindings for the DataGridView's
combo box.
Any ideas??
Brian