Solved

how to handle a keyboard event on a user control

Posted on 2013-01-15
1
333 Views
Last Modified: 2013-01-19
hi -- i'm using vs2010 and .net 4
i have a user control, where the focus is frequently in a one of several possible numerical updown controls on the user control. i want to trap a left or right arror to shift focus to the next numerical control. do i have to add event handlers for each numeric control? also, i want to trap on a tab key. a tab press currently shift focus to the next control as identified on the tab index, but i need to add some logic on that move. what event do i use to capture the tab press?
thanks,
0
Comment
Question by:jdcoburn
1 Comment
 
LVL 8

Accepted Solution

by:
Crashman earned 500 total points
ID: 38779520
you can use keydown in Form, you must active keypreview in properties.

private void Form_KeyDown(object sender, KeyEventArgs e)
{
                if (e.KeyCode == Keys.Enter)
                {
                    SendKeys.Send("{TAB}");
                }
               //for arrows
               //e.KeyCode == Keys.Left
               //e.KeyCode == Keys.Right
              //to check activecontrol use  this.ActiveControl
               
}

Open in new window

0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

813 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now