16,556
社区成员
发帖
与我相关
我的任务
分享
Dim intRow As Integer
intRow = DataGridView1.CurrentCell.RowIndex
If DataGridView1.Rows(intRow).HeaderCell.Selected = True Then
。。。。
End if
'将8楼的回复修正一下,因为如果只选择一行的话,结果不准确
Dim MaxRow As Integer = -1, MinRow As Integer = -1
For i As Integer = DataGridView1.Rows.Count - 1 To 0 Step -1
If DataGridView1.Rows(i).Selected = True Then
If MaxRow = -1 Then
MaxRow = i : MinRow = i
Else
MinRow = i
End If
End If
Next
MsgBox("您选择的最大行号是:" & MaxRow.ToString & "最小行号是:" & MinRow.ToString)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim MaxRow As Integer = 0, MinRow As Integer = 0
For i As Integer = DataGridView1.Rows.Count - 1 To 0 Step -1
If DataGridView1.Rows(i).Selected = True Then
If MaxRow = 0 Then MaxRow = i Else MinRow = i
End If
Next
MsgBox("您选择的最大行号是:" & MaxRow.ToString & "最小行号是:" & MinRow.ToString)
End Sub