473,396 Members | 1,780 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Making ENTER work as TAB for the application - HOW???

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,
AB

--

You don't pay to get spam, why pay to clean it?
Visit http://www.spammarshall.com to create an account for free
<http://www.spammarshall.com>
Nov 15 '05 #1
4 8897
Ali,

Why not set a KEY_PRESS handler up for the form and intercept the
message before it is dispatched to the controls? You can make a
determination based on the handle of the control that the message is
destined for. Also, you will want to set the KeyPreview property of the
form to true.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Ali Baba" <al*****@cricketnetwork.com> wrote in message
news:3F**************@cricketnetwork.com...
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,
AB


--

You don't pay to get spam, why pay to clean it?
Visit http://www.spammarshall.com to create an account for free

Nov 15 '05 #2
Why not use inheritance..

Extend the edit control to handle the enter key, and
replace all the edit controls on your form...

HTH
-----Original Message-----
Hi,

I need the enter key to work as a tab so that the focus goes to the nextcontrol. I don't want to write a KEY_PRESS handler for all controls. Isthere a better way? IMPORTANT: I only want this for Edit controls thatdo NOT allow multiple lines. No other control besides Edit Controlshould have this behavior
Regards,
AB

--

You don't pay to get spam, why pay to clean it?
Visit http://www.spammarshall.com to create an account for free<http://www.spammarshall.com>

Nov 15 '05 #3
I use the enter key as a tab on almost all of my controls (textbox,
combobox,...)...
Suppose I have a textbox:

class MyTextBox : TextBox
{
private Control nextItem;
public Control NextItem
{
get, set...
}

....

protected override OnKeyPressed(...)
{
// if key is enter(13) and nextItem != null then call
nextItem.Focus()
}
}

hope it helps :)
saso

"Eddie" <an*******@discussions.microsoft.com> wrote in message
news:01****************************@phx.gbl...
Why not use inheritance..

Extend the edit control to handle the enter key, and
replace all the edit controls on your form...

HTH
-----Original Message-----
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,
AB

--

You don't pay to get spam, why pay to clean it?
Visit http://www.spammarshall.com to create an account

for free
<http://www.spammarshall.com>

Nov 15 '05 #4
Ali Baba <al*****@cricketnetwork.com> wrote in news:3FB91754.2060500
@cricketnetwork.com:
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


Very easy:
private void General_KeyDown(object sender,
System.Windows.Forms.KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
SendKeys.Send("{TAB}");
}
}

Now, add this eventhandler to the KeyDown event of every control
that should have this enter==tab behaviour. You can add more than 1 event
handler to an event. You can add the same handler (the one I mentioned
above) to more than one control.

FB

--
Get LLBLGen Pro, the new O/R mapper for .NET: http://www.llblgen.com
Nov 15 '05 #5

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

Similar topics

12
by: foldface | last post by:
Hi In the example below on a normal size screen everything looks the way you would think it would (on IE6). My problem is what happens when I add more entries into the table (equivilent here to...
0
by: Huw Lloyd | last post by:
I am trying to develop a small VB.NET server application that runs in the background and places an icon in the Windows Taskbar. When the user double clicks on the taskbar icon the application...
4
by: Corey | last post by:
I have a Access database that I want about 10 users across the country to access. Currently the application sits on a local server and the users that are connecting to the server from far away,...
1
by: Matthew Wieder | last post by:
Hi - I wanted to capture the enter button on a form since I have a datagrid with the first column being a delete button and if someone hits enter it deletes the first record. I coded: private...
1
by: shanthsp2002 | last post by:
Do any expert know how to use progressbar with a application suppose i am copying files from one location to other, then at that time i would like to know the % completed ,total time...
2
by: Chandru.Kundagol | last post by:
Dear Friends, I hav done some coding in visual c++ MFC based application it runs fine in my PC(windows) when i run it on some other PC(which doesnt hav microsoft visual studio tool) it doesn' t...
1
by: rohit331 | last post by:
hi I am making a Desktop Application just like Microsoft Power Point I want to make a frame where templete styles are displayed please help it is urgent
1
by: bhatiapria | last post by:
hi i have to make a program in java i just want to make it executatable by simply clicking on a desktop icon pls help me in doing this in an application
7
by: ojsimon | last post by:
Hi I found this script on a forum and have been trying to make it work, but all it returns is a blank screen, i tried using the debug error reporting but got nothing from that either just a blank...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.