How to get the TEXT of Datagridview Combobox selected item?

前端 未结 5 856
渐次进展
渐次进展 2021-02-04 14:04

How to get the Combobox selected item text which is inside a DataGridView? I have tried using the below code:

dataGridView1.Rows[1].Cells[1].Val         


        
5条回答
  •  甜味超标
    2021-02-04 15:03

    To get selected value and selected text of Combobox in DataGridView try following Code

    string SelectedText = Convert.ToString((DataGridView1.Rows[0].Cells["dgcombocell"] as DataGridViewComboBoxCell).FormattedValue.ToString());
    int SelectedVal = Convert.ToInt32(DataGridView1.Rows[0].Cells["dgcombocell"].Value);
    

提交回复
热议问题