Private Sub Btnadditem_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
DataGridView1.ColumnCount = 4
DataGridView1.Columns(0).Name = "Product ID"
DataGridView1.Columns(1).Name = "Product Type"
DataGridView1.Columns(2).Name = "Product_name"
DataGridView1.Columns(3).Name = "Product_price"
Dim row As String()
row = New String() {TextBox2.Text, TextBox3.Text, TextBox4.Text, TextBox5.Text, "10"}
DataGridView1.Rows.Add(row)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Form2.ShowDialog()
DataGridView1.Rows.Add(Form2.RowSelect)
End Sub
อันนี้ ของ Form2 Code (VB.NET)
Public RowSelect(3) As String
Private Sub ProduceDataGridView_CellContentDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles ProduceDataGridView.CellContentDoubleClick
Me.Text = ProduceDataGridView.CurrentRow.Cells(0).Value
RowSelect(0) = ProduceDataGridView.CurrentRow.Cells(0).Value
RowSelect(1) = ProduceDataGridView.CurrentRow.Cells(1).Value
RowSelect(2) = ProduceDataGridView.CurrentRow.Cells(2).Value
RowSelect(3) = ProduceDataGridView.CurrentRow.Cells(4).Value
Me.Close()
End Sub