If DataGridView1.RowCount <= 0 Then Exit Sub
'วนลูปหา แถวที่ถูกคลิก
For Each r As DataGridViewRow In DataGridView1.Rows
If r.Cells.Item("Status").Value = "True" Then 'แถวไหนที่ถูก check ให้ไปเพิ่มข้อมูลใน Grid ตัวที่ 2
With DataGridView2
Dim rc As Integer = DataGridView2.RowCount
.Rows.Add()
.Rows(rc).Cells("Status").Value = r.Cells.Item("Status").Value
.Rows(rc).Cells("FirstName").Value = r.Cells.Item("FirstName").Value
.Rows(rc).Cells("Gender").Value = r.Cells.Item("Gender").Value
End With
End If
Next
'ลบแถวที่ถูกคลิก
For i As Integer = DataGridView1.RowCount - 1 To 0 Step -1
If DataGridView1.Rows(i).Cells("Status").Value = "True" Then
DataGridView1.Rows.RemoveAt(i)
End If
Next
Tag : .NET, Ms SQL Server 2008, Crystal Report, C#, VS 2010 (.NET 4.x)
'System.Windows.Forms.DataGridViewCellCollection' does not contain a definition for 'Item' and no extension method 'Item' accepting a first argument of type 'System.Windows.Forms.DataGridViewCellCollection' could be found (are you missing a using directive or an assembly reference?)
Private Sub DataGridView1_CellDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellDoubleClick