I have a data table, and one column is the foreign key of an integer identifier for another database table.
I have a data grid, and I would like to use a combo column to allow the user to change the value. But instead of using integers, it would be great to use names.
I tried to create a simple structure with public members int ID and string Name; The dictionary also looked into the enumerations (however, the values ββare not known at compile time), but have not yet received anything to work.
I was able to populate the combo box with structure values, but could not programmatically set the selected item / index; those. if identifier "5" is in the data table, set the structure that has identifier 5 for the selected element of the combined field.
So, to be clear, I want:
gridview datasource fk ID 1 2 3 Foreign Key table: ID Name 1 Name 1 2 Name 2 3 Name 3
The Datagridviewcombobox column must be loaded with three elements; should appear as "Name 1, Name 2, Name 3". Based on the FK identifier of the gridview data source, the selected item for each must match.
source share