0

I've searched a lot about the way of getting inedx of selected item of combobox inside datagridview but i have not found it !!

I can get the value of selected item by :

dataGridView1[j,i]->FormattedValue

But i can't get the index !

i've tried to cast DataGridView to DataGridViewComboBoxCell to use (SelectedIndex) property

DataGridViewComboBoxCell ^ t =  dynamic_cast<DataGridViewComboBoxCell ^>(dataGridView1[j,i])

but there isn't any propery shown for "t" !

4

1 回答 1

0

DataGridViewComboBoxCell 不跟踪选定的索引。

您可以使用它的编辑控件 DataGridViewComboBoxEditingControl 来获取内部 ComboBox,但它会很笨拙。

您可以做的最简单的事情是通过IndexOf查找用于初始化 DataGridViewComboBoxColumn 的所有可能值集合中的单元格值。

于 2012-12-29T23:24:33.633 回答