【发布时间】:2023-03-06 16:45:02
【问题描述】:
我有两个datagrid gridproperty 和gridpropertyselection。有一个包含数据的表。我必须根据 gridProperty datagrid 中的选定行在名为 gridpropertyselection 的 datagridviw 中填充数据。
我想为此举办哪个活动。我尝试了以下代码。但是在 Dim index As Integer = gridProperty.CurrentRow.Index 这一行中出现错误
Private Sub gridProperty_SelectionChanged(ByVal Sender As Object, ByVal e As System.Windows.Forms.DataGridViewRowStateChangedEventArgs) Handles gridProperty.RowStateChanged
Dim dtPropertySelection As DataTable = m_ds.Tables(0)
Dim i As Integer
Dim count As Integer = gridPropertySelection.Rows.Count
' If (gridProperty.CurrentRow.IsNewRow IsNot Nothing) Then
Dim index As Integer = gridProperty.CurrentRow.Index
Dim PropertyID As Integer = gridProperty.Rows(index).Cells("PropertyID").Value
While i < dtPropertySelection.Rows.Count
If PropertyID = dtPropertySelection.Rows(i).Item("PropertyID") Then
gridPropertySelection.Rows.Add()
gridPropertySelection.Rows(count).Cells("colSelectionDescription").Value() = dtPropertySelection.Rows(i).Item("SelectionDescription")
gridPropertySelection.Rows(count).Cells("colAssociatedText").Value() = dtPropertySelection.Rows(i).Item("AssociatedText")
count = count + 1
End If
i = i + 1
End While
【问题讨论】:
标签: vb.net datagridview datagrid