Solved

how to handle a keyboard event on a user control

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
comparing string in C# 3 33
Exception in Log4Net 1 19
Problem to open Excel file 15 40
Why don't I see this table in EDMX file? 2 20
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
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!
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

706 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

20 Experts available now in Live!

Get 1:1 Help Now