473,748 Members | 6,418 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can {Enter} tab to the next control?

Is there an easy way to make the {Enter} key take the cursor to the next
control without using a KeyDown event on each control?
Nov 16 '05 #1
3 5127
I haven't tried this, however, you might try wiring up a message filter
(IMessageFilter ) and add it to the mix using the
Application.Add MessageFilter() method. You could check for an Enter key
press, eat that message, and then throw a Tab key press in it's place. This
may have consequences such as not being able to break to a new line in a
multiline TextBox, and maybe some other issues as well. But this should
place your Enter key handling at the application level.

--
Tim Wilson
..Net Compact Framework MVP

"Keith Smith" <ke*********@ve rizon.net> wrote in message
news:u1jXd.2927 9$uc.19146@trnd dc09...
Is there an easy way to make the {Enter} key take the cursor to the next
control without using a KeyDown event on each control?

Nov 16 '05 #2
Oh, some other side effects could be the user not being able to select the
default accept button on a form or not being able to simulate a button press
when it has focus. So a solution at the application level may be too high up
to be done realistically. Unless, of course, you handle all the necessary
cases by checking where the message is directed and allowing certain Enters
to get through. If its not obvious, I'm really just thinking out loud on
this one.

--
Tim Wilson
..Net Compact Framework MVP

"Tim Wilson" <TIM(UNDERSCORE )WILSON(AT)ROGE RS(PERIOD)COM> wrote in message
news:uL******** ********@TK2MSF TNGP12.phx.gbl. ..
I haven't tried this, however, you might try wiring up a message filter
(IMessageFilter ) and add it to the mix using the
Application.Add MessageFilter() method. You could check for an Enter key
press, eat that message, and then throw a Tab key press in it's place. This may have consequences such as not being able to break to a new line in a
multiline TextBox, and maybe some other issues as well. But this should
place your Enter key handling at the application level.

--
Tim Wilson
.Net Compact Framework MVP

"Keith Smith" <ke*********@ve rizon.net> wrote in message
news:u1jXd.2927 9$uc.19146@trnd dc09...
Is there an easy way to make the {Enter} key take the cursor to the next
control without using a KeyDown event on each control?


Nov 16 '05 #3
You could do it on a key event for the form, if you set the form.KeyPreview
to true. Or you could override the ProcessCmdKey() for the form. However,
it's not hard to have each control handle the KeyDown. You could call a
method in the Load() event of your form to attach them all. Something like:

void AttachKeyDownTo Controls(Contro lCollection ccoll)
{
foreach ( Control c in ccoll.Controls )
{
if ( c.Controls != null )
{
AttachKeyDownTo Controls( c.Controls )
}
else
{
c.KeyDown += <whatever it is you do when you attach a KeyDown
event>;
}
}
}

This sort of thing works well if you only want to attach them to a certain
type of control. In the "else", you might really say

else if ( c is TextBoxBase && !c.Multiline )
// not sure if TextBoxBase really has multiline property but you get the
idea)
c.KeyDown += ...

"Keith Smith" <ke*********@ve rizon.net> wrote in message
news:u1jXd.2927 9$uc.19146@trnd dc09...
Is there an easy way to make the {Enter} key take the cursor to the next
control without using a KeyDown event on each control?

Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
4195
by: Ali Eghtebas | last post by:
Hi, I have 3 questions regarding the code below: 1) Why can't I trap the KEYDOWN while I can trap KEYUP? 2) Is it correct that I use Return True within the IF-Statement? (I've already read the documentation but it is rather hard to understand so please don't refer to it :) 3) Many examples in the newsgroups use Return MyBase.ProcessKeyPreview(m) as the last code line while I have used Return MyBase.ProcessKeyEventArgs(m)
6
14706
by: Terry | last post by:
I have a form which is displayed in Datasheet View and would prefer it if, when entering data, I could use the keyboard as I would when entering data into a Datasheet. Is it possible when entering data into a form to get the cursor to move to the next control after I press the Enter key? Terry
4
8912
by: Ali Baba | last post by:
Hi, I need the enter key to work as a tab so that the focus goes to the next control. I don't want to write a KEY_PRESS handler for all controls. Is there a better way? IMPORTANT: I only want this for Edit controls that do NOT allow multiple lines. No other control besides Edit Control should have this behavior Regards,
0
1243
by: Mike Kingscott | last post by:
Totally hacked off here. I've written a user control that contains a text box, a required field validator and a button (these being the cornerstone of a search facility), all as ASP.Net server controls. The user clicks the button, and server-side code does a redirect to a search page, appending the search expression to the URL. Great, I thought, let's move on. I then wrote an mailing list page which included the aforementioned user...
5
3133
by: ewillyb | last post by:
Hi, ASP.NET has some interesting behavior when the user hits the Enter key. If there are multiple ASP:Buttons (rendered as HTML submits) on the form, when the user hits enter, the first button's click event will fire and the page will submit. I have a series of pages with Previous and Next navigational Btns. The Previous button is the first button, so when the user hits enter, the previous page is served up. Enter should result in...
12
7381
by: SJ | last post by:
Hope someone can help me out there I'm struggling with a particular problem... I have a form with many tab pages. On one tab page I've got a button which when clicked with a mouse adds items into a datagrid. When a user presses the enter key on this button I want the mouse click event to be activated but instead the tab page's validating event is called. I understand that this behaviour is by partly by design (Accept button etc) but I...
1
10949
by: Andrew | last post by:
Hi! I'm new to c# and I stumbled across this dillema during a project: can anyone tell me how I can emulate the action af a Tab when enter is pressed? I saw something in visual basic that looked like this: "To allow the Enter key to function as a Tab, enter this code in the KeyPress event of your text boxes: Sub Text1_KeyPress (KeyAscii As Integer) If KeyAscii = 13 Then 'Enter SendKeys "{Tab}"
4
2401
by: portCo | last post by:
Hello there, I am using Visual Basic 2005. I want to store a value when I press enter key on the keyboard. Could anyone help me out? Thanks alot.
24
8440
by: MichaelK | last post by:
Who knows how to prevent submitting a form on the press Enter button before all fields on the form are filled up. People just enter the first field hit Enter and it submits the form and doing validation, of course flushing with the bunch of messages because rest of the fields are empty. I remember I had some pages where wrote the code to go on the next field when pressed the Enter button (Tab like), because it didn't go anywhere at all....
0
8987
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8826
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9366
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9316
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6793
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6073
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4597
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2777
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2211
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.