I'm developing a WinForm app in C# (VS 2008).
I have a DataGridView
bound to a DataTable
(Fields) and one additional column - ComboBoxColumn
. It is called RefFieldName and it is binded the same fieldsdatatable. It fills the column (RefFieldId) in this DataGridView
with ID of a field chosen in the ComboBox
.
Everything works except of displaying the name of field when my RefFieldId cell is already set. I need to display a name of the field with ID from RefFieldId in my ComboBox
cell.
How do I refresh my ComboBox
in this way?
Okey!
I've found the solution, but it is not as elegant as I expected.
I've written a method that for each record checks all records in the table and looks for fit. Then it updates the Name:
row.Cells["RefFieldName"].Value = refRow.Cells["FieldName"].Value;
Then It is necessary to handle event DataError and create an empty method for that. If somebody knows better solution it would be great!
Regards, Kuba.