从 DataGridViewComboBoxColumn 和行索引中检索组合值

Retrieve combo value from DataGridViewComboBoxColumn & Row index from DataGrid

我在 VB.Net 中使用 DataGridView 控件,其中一列是未绑定的 DataGridViewComboBoxColumn。

用户可以select 组合控件中的 4 个条目之一。 我需要确定组合框 content/selection 实际上是什么。目前,我无法检索此内容。

我已尝试使用 AddHandler combo.SelectionChangeCommitted(),按照本网站上提出的其他问题之一的建议,但此事件的参数都没有(ByVal sender As System.Object,ByVal e As System.EventArgs) ,将使我能够检索此组合控件所在的数据网格的实际行。

这很重要,因为网格的行索引是我的 Dictionary 对象中相关条目的键。

根据你说的和你的问题标题(组合框全部选中):

  Dim ComboValue As String
  Dim ComboIndex As Integer
  Dim MyDict As New Dictionary(Of String, Integer)

   For i As Integer = 0 To My_DGV.SelectedCells.Count - 1

       ComboIndex = My_DGV.SelectedCells.Item(i).RowIndex
       ComboValue = My_DGV.Rows(ComboIndex).Cells("YourDatagridviewComboboxCell").Value
       MyDict.Add(ComboValue, ComboIndex)

   Next