'DataGridView1的数据源是表1,DataGridView2的数据源是表2
'以下是DataGridView1双击事件代码
Private Sub DataGridView1_CellDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellDoubleClick
Dim NewRow As DataRow
NewRow = MyDs.Tables("表2").NewRow '如果数据集中的表名是“表1”,而另一个结构相同的表名是“表2”
NewRow("菜品名称") =MyDs.Tables("表1").Rows(Me.DataGridView1.CurrentRow.Index)(0)
NewRow("单价") = MyDs.Tables("表1").Rows(Me.DataGridView1.CurrentRow.Index)(1)
MyDs.Tables("表2").Rows.Add(NewRow)
End Sub
'以下是DataGridView1双击事件代码
Private Sub DataGridView1_CellDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellDoubleClick
Dim NewRow As DataRow
NewRow = MyDs.Tables("表2").NewRow '如果数据集中的表名是“表1”,而另一个结构相同的表名是“表2”
NewRow("菜品名称") =MyDs.Tables("表1").Rows(Me.DataGridView1.CurrentRow.Index)(0)
NewRow("单价") = MyDs.Tables("表1").Rows(Me.DataGridView1.CurrentRow.Index)(1)
MyDs.Tables("表2").Rows.Add(NewRow)
End Sub