• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2657
  • Last Modified:

how to enable arrow key navigation in datagridview using vb.net

Hello,

I hope someone has an easy, reasonable answer to my dilemma. I'm using an unbound datagridview and I would like to be able navigate through the records using the UP and Down keys. Currently, I'm able to navigate with the mouse only. I don't know if showing my code will help but I think the answer is applicable regardless of code.

Thank you in advance for your help
0
mkarkoukli
Asked:
mkarkoukli
  • 6
  • 6
1 Solution
 
jpaulinoCommented:
It's better to show some code!
0
 
mkarkoukliAuthor Commented:
The following code shows how I am loading the datagridview
 Private Sub GetTickets()
 
        Dim strSQLWhere As String
        Dim strSQLOrderBy As String
 
        strSQLWhere = "WHERE tblTicketsQueue.fkStatus NOT LIKE " & Statusclosed & " AND tblTicketsQueue.MarkForDeletion NOT LIKE 1 "
        strSQLOrderBy = "ORDER BY pkTicketID DESC"
 
        Try
            TicketList = TicketsDB.GetTickets(strSQLWhere, strSQLOrderBy)
            DataGridViewTickets.DataSource = TicketList
            ColorCodeRows()
            ArrangeGridData()
 
            Me.txtTicketsCount.Text = DataGridViewTickets.RowCount
        Catch ex As Exception
            MessageBox.Show(ex.Message, ex.GetType.ToString)
        End Try
    End Sub

Open in new window

0
 
jpaulinoCommented:
No problem with that, but you normally can use the arrow keys in the datagridview. Do you use any code for the keyboard events ?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
mkarkoukliAuthor Commented:
I'm not using any code for the arrow keys even. First I thought the datagridview has some functionality and 2nd when I click the Up and Down keys they don't do anything...
0
 
jpaulinoCommented:
But you're using any code for some keyboard events ? Can you show a screenshot of your grid ?
0
 
mkarkoukliAuthor Commented:
I'm not using any code for the keyboard events! and when I click the UP and Down keys nothing the selector doesn't move in the datagridview.
0
 
jpaulinoCommented:
Strange ... in a normal behavior of the datagridview you can move with the arrow keys on the cells or do you mean other thing for move record ? How do you do with the mouse ?
0
 
mkarkoukliAuthor Commented:
I can only select using the mouse. I wonder if I have set up some properties accidentally. Are you aware of any property  that might cause the disabling of the arrow keys.
0
 
jpaulinoCommented:
>> Are you aware of any property  that might cause the disabling of the arrow keys.
I don't remember any one!
Why don't you add a new datagridview and try it ?
0
 
mkarkoukliAuthor Commented:
I tried your suggestion but it didn't seem to work. The funny thing, I have another datagridview box below it to show detail and in that one I am able to use the arrow keys..
0
 
mkarkoukliAuthor Commented:
I found the solution, On my click event of the datagridview I was executing some code and as a result I lost the focus, so what I did a added the as a last statement

datagridviewxx.focus   and that did it.javascript:void(0)
0
 
jpaulinoCommented:
Ok, I could not guess that. You have showed just some code.
 
But it's working! :)
 
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 6
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now