How to get the TEXT of Datagridview Combobox selected item?

前端 未结 5 793
渐次进展
渐次进展 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:01

    I managed to pull that string value out of the cell this way:

    DataGridViewComboBoxCell dgvcmbcell = dataGridView1[1, 0] as DataGridViewComboBoxCell;
    String text = dgvcmbcell.EditedFormattedValue.ToString();
    

    Easiest way to figure this out is use the debugger and look into the dgvcmdcell object. In this you will find the expandable node "base". Expand it and just look through it and you will find whatever information you need.

提交回复
热议问题