Click here to Skip to main content
15,905,316 members
Home / Discussions / C#
   

C#

 
QuestionAdvancing On Pressing Enter Pin
Roger Wright8-Jun-10 19:43
professionalRoger Wright8-Jun-10 19:43 
AnswerRe: Advancing On Pressing Enter Pin
Anshul R8-Jun-10 20:21
Anshul R8-Jun-10 20:21 
AnswerRe: Advancing On Pressing Enter Pin
Peace ON8-Jun-10 20:37
Peace ON8-Jun-10 20:37 
GeneralRe: Advancing On Pressing Enter Pin
Roger Wright8-Jun-10 20:47
professionalRoger Wright8-Jun-10 20:47 
AnswerRe: Advancing On Pressing Enter Pin
Dan Mos8-Jun-10 20:47
Dan Mos8-Jun-10 20:47 
GeneralRe: Advancing On Pressing Enter Pin
Roger Wright8-Jun-10 20:52
professionalRoger Wright8-Jun-10 20:52 
GeneralRe: Advancing On Pressing Enter Pin
Dan Mos8-Jun-10 20:55
Dan Mos8-Jun-10 20:55 
AnswerRe: Advancing On Pressing Enter Pin
Henry Minute9-Jun-10 0:19
Henry Minute9-Jun-10 0:19 
Hi Roger,

The answers give already, work perfectly well in circumstances where you know the Name of the control that you want to go to and are prepared to write an individual KeyDown/Keypress (select your poison) handler for each control. However, for circumstances where you want to simply follow the TabOrder you have already set and, where applicable, use one handler for several controls, the System.Windows.Forms.Control class has a built in method to do exactly what you want. Look up the System.Windows.Forms.Control.GetNextControl() method.

An example:
C#
private void Comunal_KeyDownHandler(object sender, System.Windows.Forms.KeyEventArgs e)
{
   if (e.KeyCode == Keys.Enter)
   {
       e.Handled = true;
       // true means go forwards
       this.GetNextControl((Control)sender, true).Focus();
   }
}


This way you can assign the handler to all the controls in your User Control, provided that you are not already using their KeyDown event for something else.
Henry Minute

Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
Why do programmers often confuse Halloween and Christmas?
Because 31 Oct = 25 Dec.

AnswerRe: Advancing On Pressing Enter Pin
Richard Andrew x649-Jun-10 4:39
professionalRichard Andrew x649-Jun-10 4:39 
Questionbinning at zero-filling data Pin
shekarchee8-Jun-10 19:41
shekarchee8-Jun-10 19:41 
AnswerRe: binning at zero-filling data Pin
EliottA9-Jun-10 2:19
EliottA9-Jun-10 2:19 
AnswerRe: binning at zero-filling data Pin
LookSharp9-Jun-10 3:40
LookSharp9-Jun-10 3:40 
QuestionClone Windows Forms Information Pin
Illegal Operation8-Jun-10 19:30
Illegal Operation8-Jun-10 19:30 
AnswerRe: Clone Windows Forms Information Pin
Anshul R8-Jun-10 20:27
Anshul R8-Jun-10 20:27 
AnswerRe: Clone Windows Forms Information Pin
Peace ON8-Jun-10 20:44
Peace ON8-Jun-10 20:44 
QuestionWindows application create an Excel file Pin
Member 44642398-Jun-10 11:45
Member 44642398-Jun-10 11:45 
AnswerRe: Windows application create an Excel file Pin
Dan Mos8-Jun-10 11:59
Dan Mos8-Jun-10 11:59 
AnswerRe: Windows application create an Excel file Pin
Ramkithepower9-Jun-10 4:01
Ramkithepower9-Jun-10 4:01 
Questionwindows application Pin
jashimu8-Jun-10 8:36
jashimu8-Jun-10 8:36 
AnswerRe: windows application Pin
Manas Bhardwaj8-Jun-10 9:08
professionalManas Bhardwaj8-Jun-10 9:08 
AnswerRe: windows application [modified] Pin
#realJSOP8-Jun-10 10:04
professional#realJSOP8-Jun-10 10:04 
AnswerRe: windows application Pin
LookSharp9-Jun-10 3:54
LookSharp9-Jun-10 3:54 
GeneralRe: windows application Pin
jashimu9-Jun-10 7:56
jashimu9-Jun-10 7:56 
QuestionLINQ DataContext and IDisposable Pin
Member 39190498-Jun-10 7:01
Member 39190498-Jun-10 7:01 
AnswerRe: LINQ DataContext and IDisposable Pin
Pete O'Hanlon8-Jun-10 10:01
mvePete O'Hanlon8-Jun-10 10:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.