Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Looking for a way to use ENTER to move between controls
Message
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Title:
Looking for a way to use ENTER to move between controls
Environment versions
Environment:
C# 2.0
OS:
Windows Server 2003
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Desktop
Miscellaneous
Thread ID:
01378498
Message ID:
01378498
Views:
61
In FoxPro, there was a setting that would allow users to move between controls using either ENTER or TAB, as they had in DOS. I have an application which has quite a few numbers to be entered and the users would like to be able to use the enter key after entering the numbers because they use the number pad for entry. I tried using some code in my base form class that would trap the ENTER key stroke and replace it with a TAB but that causes problems when the field is a multi-line text box and the ENTER key needs to behave as an ENTER key. Is there some setting for this or should I just build a custom numeric control that traps the ENTER key? Thanks.

I tried doing a custom control, adding the following override for the OnKeyPress event:
        protected override void OnKeyPress(KeyPressEventArgs e)
        {
            switch (e.KeyChar)
            {
                case '\r': // enter key
                    e.Handled = true;
                    base.OnLeave(e);
                    break;
                default:
                    base.OnKeyPress(e);
                    break;
            }
        }
It still just ignores the ENTER key. I had hoped to force a TAB keystroke when ENTER is pressed but apparently you can't trap or force a TAB key using KeyChar. Any ideas?
Linda Harmes
HiBit Technologies, Inc.
Next
Reply
Map
View

Click here to load this message in the networking platform