Solved

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

Posted on 2009-04-14
12
2,437 Views
Last Modified: 2012-06-21
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
Comment
Question by:mkarkoukli
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 6
12 Comments
 
LVL 48

Expert Comment

by:jpaulino
ID: 24143664
It's better to show some code!
0
 

Author Comment

by:mkarkoukli
ID: 24143750
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
 
LVL 48

Expert Comment

by:jpaulino
ID: 24143763
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:mkarkoukli
ID: 24143786
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
 
LVL 48

Expert Comment

by:jpaulino
ID: 24143822
But you're using any code for some keyboard events ? Can you show a screenshot of your grid ?
0
 

Author Comment

by:mkarkoukli
ID: 24143837
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
 
LVL 48

Expert Comment

by:jpaulino
ID: 24144072
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
 

Author Comment

by:mkarkoukli
ID: 24144879
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
 
LVL 48

Expert Comment

by:jpaulino
ID: 24145747
>> 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
 

Author Comment

by:mkarkoukli
ID: 24149566
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
 

Author Comment

by:mkarkoukli
ID: 24150523
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
 
LVL 48

Accepted Solution

by:
jpaulino earned 500 total points
ID: 24150718
Ok, I could not guess that. You have showed just some code.
 
But it's working! :)
 
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question