Just re-read your post, this should be closer to what you are after. Or you
could use a list of datagridviewrows and return that instead.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
For Each num As Integer In SelectedRows()
Debug.Print(num.ToString)
Next
End Sub
Private Function SelectedRows() As List(Of Integer)
Dim list As New List(Of Integer)
Dim Grid As DataGridView = Me.InvoicesControl1.InvoicesDataGridView
For n As Integer = 0 To Grid.Rows.Count - 1
If CBool(Grid.Rows(n).Cells("Selected").Value) = True Then
list.Add(n)
End If
Next
Return list
End Function
HTH,
Martin.
"Martin" <@ntlworld.comwrote in message
news:In*******************@newsfe1-gui.ntli.net...
Hi Annie,
you could try something like this , just susbstitute the name of your
datagridview and the name or index of the cell that contains the checkbox.
For n As Integer = 0 To Grid.Rows.Count - 1
If CBool(YourGrid.Rows(n).Cells("Selected").Value) = True Then
Return True
End If
Next
HTH,
Martin
"Annie" <my**************@gmail.comwrote in message
news:45********@dnews.tpgi.com.au...
>hello guys,
I am having a DataGridView control.
The first column is a checkbox column.
The users can select the checkbox column. I need to loop through the grid
rows and get
the checked checkboxes and the rows numbers
I don't know how to check if the first column checkbox is checked???
any help will be appreciated!