how to set SelectedIndex in DataGridViewComboBoxColumn?

后端 未结 7 850
慢半拍i
慢半拍i 2021-01-18 04:00

i am using a datagridview in that i am using a datagridviewcomboboxcolumn, comboboxcolumn is displaying text but the problem is i want to select the first item of comboboxco

7条回答
  •  暖寄归人
    2021-01-18 05:02

    You need to set the Items for the new cell. This must be auto done by the column when creating a new row from the UI.

     var cell = new DataGridViewComboBoxCell() { Value = "SomeText" };
     cell.Items.AddRange(new String[]{"SomeText", "Abcd", "123"});
    

提交回复
热议问题