Question DataGridView related combobox description?

Joe1

Active member
Joined
Dec 4, 2012
Messages
37
Programming Experience
Beginner
I have a DataGridView box within a windows application form, the initial column is "Parameter" which is a combobox, then the second column is "Description". I would like a description of the relevant parrameter to show in the description when a parameter is selcted?

Can this be done in the DataGridView as I have explained? How can this be done?
 
Handle the CellValueChanged event of the grid and test for when the change is in that combo box column. When it is, get the Value from the current cell and use it to look up the corresponding Description and set the Value of the appropriate cell.
 
Would this be the only way to do this, as it seems like the process would have to be completed for every event seperately?
In the database I have a large amount of Parameters and Associated descriptions.. so is there that automatically link "Parameter" column selection with "Description" for all options
 
When you retrieve the parameter data in the first place you should be getting the ID, name and description and populating a DataTable with those three columns. You would bind that DataTable to your combo box column, specifying the name column as the DisplayMember and the ID column as the ValueMember. When the user selects a name from the drop-down list, the corresponding ID is what gets assigned to the cell's Value, thus setting up the parent/child relationship between the parameter table and the table displayed in the grid proper. Once the cell contains the ID you can get it and use to go back to the original DataTable, get the corresponding row and get the description from that.
 
Back
Top