0

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?

Dave Clemmer
  • 3,741
  • 12
  • 49
  • 72
Kuba Matjanowski
  • 350
  • 3
  • 14
  • 1
    What is teh datasource for you custom ComboBox? have you bound it to one of teh original columns in the dtaatable via DataPropertyName? – Derek Apr 30 '13 at 11:20
  • Yes! it is bounded to column RefFiedId in the table in my dataset. Of course I defined Name of field as DisplayMember and id of field as ValueMember. – Kuba Matjanowski May 11 '13 at 16:54

1 Answers1

0

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.

Kuba Matjanowski
  • 350
  • 3
  • 14