' selected girdview rows using keyboard operate
Private Sub gdv_route_points_list_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles gdv_route_points_list.KeyDown
Dim index As Integer = Me.gdv_route_points_list.SelectedRows(0).Index
If index < 0 Or index > Me.gdv_route_points_list.Rows.Count Then
Return
End If
If e.KeyValue = &H26 And index > 0 Then
Me.gdv_route_points_list.Rows(index - 1).Selected = True
Me.gdv_route_points_list_CellClick(Nothing, Nothing)
ElseIf e.KeyValue = &H28 And index < Me.gdv_route_points_list.Rows.Count - 1 Then
Me.gdv_route_points_list.Rows(index + 1).Selected = True
Me.gdv_route_points_list_CellClick(Nothing, Nothing)
End If
End Sub
本文介绍了一个使用Visual Basic编写的事件处理程序,该程序允许用户通过键盘上下箭头键来选择GridView中的行。当用户按下上箭头键时,程序会将当前选中行的索引减一并重新选中该行;按下下箭头键时,则将当前选中行的索引加一并选中。此外,程序还包含了边界检查以确保不会超出GridView的行范围。
2849

被折叠的 条评论
为什么被折叠?



