我正在使用具有MS访问权限的vb.net。我在form1中有一个datagridview1,我希望使用复制按钮将选中的行复制到另一个datagridview2中。从datagridview1复制所选数据后,将通过以下代码删除。但我不知道如何复制数据。
Private Sub BindingNavigatorDeleteItem_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles BindingNavigatorDeleteItem.Click
Me.Validate()
Me.HPReportBindingSource.AllowRemove.ToString()
Me.TableAdapterManager.UpdateAll(Me.Histopathology_NewDataSet1)
MsgBox("Saved")
End Sub
答案 0 :(得分:0)
确保2个datagridviews具有相同的列数
Private Sub BindingNavigatorDeleteItem_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles BindingNavigatorDeleteItem.Click
If DataGridView1.SelectedRows.Count > 0 Then
Dim selectedgrid As DataGridViewRow = DataGridView1.SelectedRows(0)
DataGridView1.Rows.Remove(selectedgrid)
DataGridView2.Rows.Add(selectedgrid)
End If
End Sub