Failed to set selected items for DataGridView ComboBox

I got confused about setting / getting selected combobox field indexes inside.

this.Parameter.DataSource = lambdacat.Dict(); { foreach (DataGridViewRow row in LimView.Rows) { //( (ComboBox)row.Cells[1] ) ??? } } 

yes it does not work :)

Thank you

+4
source share
1 answer

you can use

 (row.Cells[1] as DataGridViewComboBoxCell).Value == yourvalue; 

and get the selected value as

 (row.Cells[1] as DataGridViewComboBoxCell).FormattedValue 

To set the default value

 (row.Cells[1] as DataGridViewComboBoxCell).Value =(row.Cells[1] as DataGridViewComboBoxCell).Items[yourneededindex] 
+5
source

All Articles