Dim selectedRows As List(Of DataGridViewRow) = (From row In DataGridView1.Rows.Cast(Of DataGridViewRow)()
Where Convert.ToBoolean(row.Cells("checkBoxColumn").Value) = True).ToList()
For i As Integer = 0 To DataGridView1.Rows.Count - 2
If DataGridView1.Rows(i).Cells(0).Value IsNot Nothing Then
New_User.ListBox1.Items.Add(Me.DataGridView1.Rows(i).Cells(0).Value.ToString)
'New_User.Label7.Text = Me.DataGridView1.Rows(i).Cells(0).Value.ToString
End If
Next
New_User.Show()
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'New_User.ListBox1.Items.Add(Me.DataGridView1(0, Me.DataGridView1.CurrentCell.RowIndex).Value.ToString())
Dim selectedRows As List(Of DataGridViewRow) = (From row In DataGridView1.Rows.Cast(Of DataGridViewRow)()
Where Convert.ToBoolean(row.Cells("checkBoxColumn").Value) = True).ToList()
For i As Integer = 0 To DataGridView1.Rows.Count - 2
If DataGridView1.Rows(i).Cells(0).Value IsNot Nothing Then
New_User.ListBox1.Items.Add(Me.DataGridView1.Rows(i).Cells(0).Value.ToString)
'New_User.Label7.Text = Me.DataGridView1.Rows(i).Cells(0).Value.ToString
End If
Next
Me.Close()
'Dispose()
End Sub
ผมใช้วิธีนี้ครับ หน้าส่ง
Code (VB.NET)
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim frmNew As New Search_Group
frmNew.ShowDialog() '= Me.MdiParent
For i As Integer = 0 To frmNew.DataGridView1.Rows.Count - 2
If frmNew.DataGridView1.Rows(i).Cells(0).Value IsNot Nothing Then
ListBox1.Items.Add(frmNew.DataGridView1.Rows(i).Cells("GROUP_USER").Value.ToString())
End If
Next
End Sub