Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

how to handle a keyboard event on a user control

Posted on 2013-01-15
1
Medium Priority
?
339 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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

610 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