04-03-16, 06:36 AM
PHP كود :
Friend Function SelectRow(grid As DataGridView, row As Integer) As Boolean
If (row >= grid.RowCount) Then
row = (grid.RowCount - 1)
End If
If (row >= 0) Then
grid.CurrentCell = grid.Rows.Item(row).Cells.Item(0)
grid.Rows.Item(row).Selected = True
Return True
End If
Return False
End Function
Friend Function SelectRows(grid As DataGridView) As Boolean
' Method 1
'For j As Integer = 0 To grid.Rows.Count - 1
' Dim row As DataGridViewRow = grid.Rows(j)
' SelectRow(grid, row.Index)
'Next
' Method 2
For Each r As DataGridViewRow In grid.Rows
Me.SelectRow(grid, r.Index)
Next
Return False
End Function

