Click here to Skip to main content
16,020,973 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to create a new keyword Pin
Jon Rista22-Feb-09 18:10
Jon Rista22-Feb-09 18:10 
AnswerRe: How to create a new keyword Pin
damichab23-Feb-09 11:09
damichab23-Feb-09 11:09 
Questioncustomize deserialization sample in C#? Pin
George_George22-Feb-09 14:48
George_George22-Feb-09 14:48 
AnswerRe: customize deserialization sample in C#? Pin
Zap-Man22-Feb-09 15:05
Zap-Man22-Feb-09 15:05 
GeneralRe: customize deserialization sample in C#? Pin
George_George22-Feb-09 15:45
George_George22-Feb-09 15:45 
QuestionMaking the enter(return) key call a Validated event Pin
High0ctane22-Feb-09 12:54
High0ctane22-Feb-09 12:54 
AnswerRe: Making the enter(return) key call a Validated event Pin
Megidolaon23-Feb-09 3:10
Megidolaon23-Feb-09 3:10 
AnswerRe: Making the enter(return) key call a Validated event Pin
Richard Dean14-Apr-09 7:28
Richard Dean14-Apr-09 7:28 
Hi “High Octane”

YES YOU CAN! Been there and done it!
I am also a NEWB, I am also new to pasting replies on the code-project.

If (matter.resolved==false)
{
Read on!
}


I am assuming you are want to use the return/enter key to move from one textbox to another but validating the data that has been entered.
A group of textboxes for example? with the "Type in data then press enter" option?

I am not sure how you are validating your data but assume that you use the “Causes validation” property of the textbox. Personally I have a separate validation method fired by the leave event of the textbox.
I also use a keydown event for the same textbox.
In that event I call the "SelectNextControl" method once the return key was pressed.
The "SelectNextControl" method does what it says on the tin, but There are five parameters to it.
These are:-

Ctl
The Control at which to start the search.

forward
true to move forward in the tab order; false to move backward in the tab order.

tabStopOnly
true to ignore the controls with the TabStop property set to false; otherwise, false.

nested
true to include nested (children of child controls) child controls; otherwise, false.

wrap
true to continue searching from the first control in the tab order after the last control has been reached; otherwise, false.

Return Value
true if a control was activated; otherwise, false.


If you using a few textboxes then generate two event handlers one for keydown and one for leave and connect each textbox to the SAME EVENT HANDLER and use “case statements” switched from the name of the textbox. I can show you how to do this if necessary(just post a reply) I have about a dozen textboxes on one form and use ONE “Leave event” handler to handle EVERY ONE OF THEM and the return key can move between them.
I use the leave event to validate and enter the data into the program.
I use the keydown event is to detect if a key is down (crazy that eh!)
I have several textboxes and the use exactly the same leave and keydown event handlers, in the case below "tbxUpper"


private void tbxUpper_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Return)
            {
                TextBox tbx = (TextBox)sender;
                SelectNextControl(tbx, true, true, true, true);
            }
        }



the above event actually fires every time a key is presses in a text box but the "if statement" looks for the return key. when the return key is pressed a textbox called tbx is generated and copied from sender then the next control is selected.
I don't know if this actually helps you.
If you need furthur help post a reply "and then hit Enter"!!
QuestionC# area map Pin
Zap-Man22-Feb-09 12:01
Zap-Man22-Feb-09 12:01 
AnswerRe: C# area map Pin
fly90422-Feb-09 12:13
fly90422-Feb-09 12:13 
GeneralRe: C# area map Pin
Zap-Man22-Feb-09 14:40
Zap-Man22-Feb-09 14:40 
GeneralRe: C# area map Pin
fly90422-Feb-09 15:06
fly90422-Feb-09 15:06 
GeneralRe: C# area map Pin
Zap-Man22-Feb-09 15:18
Zap-Man22-Feb-09 15:18 
GeneralRe: C# area map [modified] Pin
fly90423-Feb-09 0:04
fly90423-Feb-09 0:04 
GeneralRe: C# area map Pin
Zap-Man23-Feb-09 13:41
Zap-Man23-Feb-09 13:41 
QuestionPassable function Pin
Chris Copeland22-Feb-09 10:04
mveChris Copeland22-Feb-09 10:04 
AnswerRe: Passable function Pin
Jon Rista22-Feb-09 10:54
Jon Rista22-Feb-09 10:54 
GeneralRe: Passable function Pin
Chris Copeland22-Feb-09 11:02
mveChris Copeland22-Feb-09 11:02 
GeneralRe: Passable function Pin
Jon Rista22-Feb-09 11:16
Jon Rista22-Feb-09 11:16 
QuestionHow to enable auto scroll in a listbox? Pin
bar300022-Feb-09 9:20
bar300022-Feb-09 9:20 
AnswerRe: How to enable auto scroll in a listbox? Pin
Luis Alonso Ramos22-Feb-09 9:34
Luis Alonso Ramos22-Feb-09 9:34 
GeneralRe: How to enable auto scroll in a listbox? Pin
bar300022-Feb-09 9:48
bar300022-Feb-09 9:48 
GeneralRe: How to enable auto scroll in a listbox? Pin
Luis Alonso Ramos22-Feb-09 10:11
Luis Alonso Ramos22-Feb-09 10:11 
GeneralRe: How to enable auto scroll in a listbox? Pin
Luis Alonso Ramos22-Feb-09 10:30
Luis Alonso Ramos22-Feb-09 10:30 
AnswerRe: How to enable auto scroll in a listbox? Pin
Luc Pattyn22-Feb-09 10:11
sitebuilderLuc Pattyn22-Feb-09 10:11 

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.