我有一个动态填充的datagridview。我希望根据某些条件在某些列中填充组合框。
但是我的组合框单元被添加到最底部的行而不是正确的行。
谁能告诉我需要做什么?
我哪里错了?
Private Sub dgvSteps_CellContentClick(ByVal sender As Object,
ByVal e As DataGridViewCellEventArgs
) Handles dgvSteps.CellContentClick
Dim reader = New XmlTextReader("C:\Qualcomm\" & tempNode.profilePath)
reader.WhitespaceHandling = WhitespaceHandling.None
reader.Read()
reader.Read()
reader.Read()
dgv2.Rows.Clear()
While reader.NodeType <> XmlNodeType.EndElement
Dim str1 As String
Dim str2 As String
str1 = reader.Name
str2 = reader.ReadElementString(str1)
If reader.Name = "Port" Then
Dim dgv2Cb As New DataGridViewComboBoxCell 'Create DatagridViewComboBoxCell
Dim ports As String() = SerialPort.GetPortNames()
Dim port As String
For Each port In ports
dgv2Cb.Items.Add(port)
Next port
dgv2Cb.Sorted = True
dgv2.Rows.Add(str1, str2)
rowIndex = dgv2.RowCount 'Get the RowCount at the time of adding combobexcell, and add comboboxcell in that row
dgv2.Rows(rowIndex).Cells(1) = dgv2Cb
Else
dgv2.Rows.Add(str1, str2)
End If
End While
End Sub