Set selected items for DataGridView ComboBox failed

后端 未结 1 1896
借酒劲吻你
借酒劲吻你 2020-12-19 21:18

I\'ve got confusion of setting / getting selected indexes of combobox fields inside.

    this.Parameter.DataSource = lambdacat.Dict();
    {
        foreach          


        
1条回答
  •  时光说笑
    2020-12-19 21:55

    You can use

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

    and get the selected value as

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

    To set a default selected value

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

    0 讨论(0)
提交回复
热议问题