Private Sub DataGridView1_DoubleClick(sender As Object, e As EventArgs) Handles DataGridView1.DoubleClick
Dim FindID As String
FindID = CStr(DataGridView1.Item(0, DataGridView1.CurrentRow.Index).Value)
If FindID <> "" Then
Try
Cursor.Current = Cursors.WaitCursor
With cn
If .State = ConnectionState.Open Then .Close()
.ConnectionString = ConStr
.Open()
End With
StrSql = ""
StrSql &= " Select *"
StrSql &= " From Alien "
StrSql &= " where id=" & FindID & ""
Da = New OleDbDataAdapter(StrSql, cn)
Ds = New DataSet
Ds.Clear()
Da.Fill(Ds, "Alien")
If Ds.Tables("Alien").Rows.Count <> 0 Then
DataGridView2.AllowUserToAddRows = True
DataGridView2.Rows.Add()
DataGridView2.Rows(i).Cells(1).Value = CStr(Ds.Tables("Alien").Rows(0).Item(1))
i = i + 1
End If
Cursor.Current = Cursors.Default
Catch ex As Exception
' MsgBox("พบข้อผิดพลาดในการทำงาน" & vbCrLf & ex.Message, MsgBoxStyle.Critical, "ผลการทำงาน")
End Try
End If
End Sub
Dim row As New DataGridViewRow()
row = DirectCast(DataGridView1.CurrentRow.Clone(), DataGridViewRow)
For Each cell As DataGridViewCell In DataGridView1.CurrentRow.Cells
row.Cells(cell.ColumnIndex).Value = cell.Value
Next
DataGridView2.Rows.Add(row)