473,763 Members | 7,611 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.spammarshal l.com>
Nov 15 '05 #1
4 8913
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.co m

"Ali Baba" <al*****@cricke tnetwork.com> wrote in message
news:3F******** ******@cricketn etwork.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.spammarshal l.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*******@disc ussions.microso ft.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.spammarshal l.com>

Nov 15 '05 #4
Ali Baba <al*****@cricke tnetwork.com> wrote in news:3FB91754.2 060500
@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.KeyEventA rgs 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
2153
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 making the IE window smaller) - If you make the window smaller then the first column text starts to wrap, which I don't want
0
1160
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 window should appear and when they minimise, it should minimise back to the task bar... Any ideas how I do this?
4
1445
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, sit around for several minutes before they can do anything-if anything at all. What types of solutions are available for me? I have read something about putting the database on a differant type of server, but i didnt seem to follow too well. Can...
1
3094
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 void Page_Load(object sender, System.EventArgs e) { Page.RegisterHiddenField("__EVENTTARGET","SomeButtonOnThePage");
1
2084
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 expected,remaining time, and progress bar should progress according to that I hope somebody can give me idea abt this thanks regards Prashanth
2
3378
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 run.I think to make it run on other PC the project should be configured properly(Release mode) before building mostly im not able to configure properly.Please help
1
913
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
1190
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
2897
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 page, here is the code<?php //In this case, it fetches a search for "fresh content" from www.alltheweb.com, whom we hope you will visit. $theLocation="http://www.alltheweb.com/search?cat=web&q=fresh+content&phrase=on&h=50"; //Below, at $start and...
0
9564
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
10148
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10002
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
9938
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,...
0
9823
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6643
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
5406
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3917
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2794
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.