Solved

how to handle a keyboard event on a user control

Posted on 2013-01-15
1
335 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
[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
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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

733 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