Hi All,
On my windows form, when the user hits the return key, I'll need to treat it
as a tab key. i.e. when the user hits a return, the focus will move to the
next item in the tab-order on the windows form.
I guess I can add a KeyDown event handler for each componet controls on the
windows form, but that does not seem to be efficient.
Can I do it at the forms level? What i'm thinking is on FORMS if I can get
this return event, I can send another tab key-down event. I know how to do
this in MFC, but not in C#.
Thanks.
WJ 7 2598
Sure, first set the Form's KeyPreview property to true: http://msdn2.microsoft.com/en-us/lib...ew(VS.80).aspx
This causes the Form to intercept KeyDown events for any Controls in the
Form. It can then pass on the event, or handle it, or both. Then handle the
KeyDown event for the Form. If you've done MFC before, the rest should be
easy.
--
HTH,
Kevin Spencer
Microsoft MVP
Ministry of Software Development http://unclechutney.blogspot.com
I just flew in from Chicago with
a man with a wooden leg named Smith
who shot an elephant in my pajamas.
So I bit him.
"Wanjun Yu" <wa*******@hotm ail.comwrote in message
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
Hi All,
On my windows form, when the user hits the return key, I'll need to treat
it as a tab key. i.e. when the user hits a return, the focus will move to
the next item in the tab-order on the windows form.
I guess I can add a KeyDown event handler for each componet controls on
the windows form, but that does not seem to be efficient.
Can I do it at the forms level? What i'm thinking is on FORMS if I can get
this return event, I can send another tab key-down event. I know how to do
this in MFC, but not in C#.
Thanks.
WJ
Thansk, Kevin.
One more question to ask though, how to send a tab key message to the form?
WJ
"Kevin Spencer" <sp**@uce.govwr ote in message
news:eU******** ******@TK2MSFTN GP02.phx.gbl...
Sure, first set the Form's KeyPreview property to true:
http://msdn2.microsoft.com/en-us/lib...ew(VS.80).aspx
This causes the Form to intercept KeyDown events for any Controls in the
Form. It can then pass on the event, or handle it, or both. Then handle
the KeyDown event for the Form. If you've done MFC before, the rest should
be easy.
--
HTH,
Kevin Spencer
Microsoft MVP
Ministry of Software Development http://unclechutney.blogspot.com
I just flew in from Chicago with
a man with a wooden leg named Smith
who shot an elephant in my pajamas.
So I bit him.
"Wanjun Yu" <wa*******@hotm ail.comwrote in message
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
>Hi All, On my windows form, when the user hits the return key, I'll need to treat it as a tab key. i.e. when the user hits a return, the focus will move to the next item in the tab-order on the windows form.
I guess I can add a KeyDown event handler for each componet controls on the windows form, but that does not seem to be efficient.
Can I do it at the forms level? What i'm thinking is on FORMS if I can get this return event, I can send another tab key-down event. I know how to do this in MFC, but not in C#.
Thanks.
WJ
Hi Wanjun,
You can select the next control in the tab order using the following method:
"Control.Select NextControl Method" http://msdn2.microsoft.com/en-us/lib...ol(VS.80).aspx
If you want to execute some code that uses the next control in the tab order
before it's focused then use the following methods instead:
"Control.GetNex tControl Method" http://msdn2.microsoft.com/en-us/lib...ol(VS.80).aspx
"Control.Se lect Method" http://msdn2.microsoft.com/en-us/lib...ea(VS.80).aspx
--
Dave Sexton
"Wanjun Yu" <wa*******@hotm ail.comwrote in message
news:O1******** ******@TK2MSFTN GP03.phx.gbl...
Thansk, Kevin.
One more question to ask though, how to send a tab key message to the form?
WJ
"Kevin Spencer" <sp**@uce.govwr ote in message
news:eU******** ******@TK2MSFTN GP02.phx.gbl...
>Sure, first set the Form's KeyPreview property to true:
http://msdn2.microsoft.com/en-us/lib...ew(VS.80).aspx
This causes the Form to intercept KeyDown events for any Controls in the Form. It can then pass on the event, or handle it, or both. Then handle the KeyDown event for the Form. If you've done MFC before, the rest should be easy.
-- HTH,
Kevin Spencer Microsoft MVP Ministry of Software Development http://unclechutney.blogspot.com
I just flew in from Chicago with a man with a wooden leg named Smith who shot an elephant in my pajamas. So I bit him.
"Wanjun Yu" <wa*******@hotm ail.comwrote in message news:%2******* *********@TK2MS FTNGP04.phx.gbl ...
>>Hi All, On my windows form, when the user hits the return key, I'll need to treat it as a tab key. i.e. when the user hits a return, the focus will move to the next item in the tab-order on the windows form.
I guess I can add a KeyDown event handler for each componet controls on the windows form, but that does not seem to be efficient.
Can I do it at the forms level? What i'm thinking is on FORMS if I can get this return event, I can send another tab key-down event. I know how to do this in MFC, but not in C#.
Thanks.
WJ
Press the TAB key?
--
HTH,
Kevin Spencer
Microsoft MVP
Ministry of Software Development http://unclechutney.blogspot.com
I just flew in from Chicago with
a man with a wooden leg named Smith
who shot an elephant in my pajamas.
So I bit him.
"Wanjun Yu" <wa*******@hotm ail.comwrote in message
news:O1******** ******@TK2MSFTN GP03.phx.gbl...
Thansk, Kevin.
One more question to ask though, how to send a tab key message to the
form?
WJ
"Kevin Spencer" <sp**@uce.govwr ote in message
news:eU******** ******@TK2MSFTN GP02.phx.gbl...
>Sure, first set the Form's KeyPreview property to true:
http://msdn2.microsoft.com/en-us/lib...ew(VS.80).aspx
This causes the Form to intercept KeyDown events for any Controls in the Form. It can then pass on the event, or handle it, or both. Then handle the KeyDown event for the Form. If you've done MFC before, the rest should be easy.
-- HTH,
Kevin Spencer Microsoft MVP Ministry of Software Development http://unclechutney.blogspot.com
I just flew in from Chicago with a man with a wooden leg named Smith who shot an elephant in my pajamas. So I bit him.
"Wanjun Yu" <wa*******@hotm ail.comwrote in message news:%2******* *********@TK2MS FTNGP04.phx.gbl ...
>>Hi All, On my windows form, when the user hits the return key, I'll need to treat it as a tab key. i.e. when the user hits a return, the focus will move to the next item in the tab-order on the windows form.
I guess I can add a KeyDown event handler for each componet controls on the windows form, but that does not seem to be efficient.
Can I do it at the forms level? What i'm thinking is on FORMS if I can get this return event, I can send another tab key-down event. I know how to do this in MFC, but not in C#.
Thanks.
WJ
Dave, Thanks. It works.
Wanjun
"Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
news:uf******** ******@TK2MSFTN GP04.phx.gbl...
Hi Wanjun,
You can select the next control in the tab order using the following
method:
"Control.Select NextControl Method" http://msdn2.microsoft.com/en-us/lib...ol(VS.80).aspx
If you want to execute some code that uses the next control in the tab
order before it's focused then use the following methods instead:
"Control.GetNex tControl Method" http://msdn2.microsoft.com/en-us/lib...ol(VS.80).aspx
"Control.Se lect Method" http://msdn2.microsoft.com/en-us/lib...ea(VS.80).aspx
--
Dave Sexton
"Wanjun Yu" <wa*******@hotm ail.comwrote in message
news:O1******** ******@TK2MSFTN GP03.phx.gbl...
>Thansk, Kevin.
One more question to ask though, how to send a tab key message to the form?
WJ
"Kevin Spencer" <sp**@uce.govwr ote in message news:eU******* *******@TK2MSFT NGP02.phx.gbl.. .
>>Sure, first set the Form's KeyPreview property to true:
http://msdn2.microsoft.com/en-us/lib...ew(VS.80).aspx
This causes the Form to intercept KeyDown events for any Controls in the Form. It can then pass on the event, or handle it, or both. Then handle the KeyDown event for the Form. If you've done MFC before, the rest should be easy.
-- HTH,
Kevin Spencer Microsoft MVP Ministry of Software Development http://unclechutney.blogspot.com
I just flew in from Chicago with a man with a wooden leg named Smith who shot an elephant in my pajamas. So I bit him.
"Wanjun Yu" <wa*******@hotm ail.comwrote in message news:%2****** **********@TK2M SFTNGP04.phx.gb l... Hi All, On my windows form, when the user hits the return key, I'll need to treat it as a tab key. i.e. when the user hits a return, the focus will move to the next item in the tab-order on the windows form.
I guess I can add a KeyDown event handler for each componet controls on the windows form, but that does not seem to be efficient.
Can I do it at the forms level? What i'm thinking is on FORMS if I can get this return event, I can send another tab key-down event. I know how to do this in MFC, but not in C#.
Thanks.
WJ
I was about to post the same question when I found this thread. We have a
custom app written in C# which does lots of strange things when our users
hit the Enter key out of habit instead of the Tab key. The programmer claims
it takes a lot of time and effort to modify the Windows forms to interpret
the Return key to be a Tab key. I suspect he's not correct. Is the above
suggestion the simplest way to cause the Enter key to always act like a Tab
key? Is this a lot of work to pull this off for a form?
- John Loewen
"Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
news:uf******** ******@TK2MSFTN GP04.phx.gbl...
Hi Wanjun,
You can select the next control in the tab order using the following
method:
"Control.Select NextControl Method" http://msdn2.microsoft.com/en-us/lib...ol(VS.80).aspx
If you want to execute some code that uses the next control in the tab
order before it's focused then use the following methods instead:
"Control.GetNex tControl Method" http://msdn2.microsoft.com/en-us/lib...ol(VS.80).aspx
"Control.Se lect Method" http://msdn2.microsoft.com/en-us/lib...ea(VS.80).aspx
--
Dave Sexton
"Wanjun Yu" <wa*******@hotm ail.comwrote in message
news:O1******** ******@TK2MSFTN GP03.phx.gbl...
>Thansk, Kevin.
One more question to ask though, how to send a tab key message to the form?
WJ
"Kevin Spencer" <sp**@uce.govwr ote in message news:eU******* *******@TK2MSFT NGP02.phx.gbl.. .
>>Sure, first set the Form's KeyPreview property to true:
http://msdn2.microsoft.com/en-us/lib...ew(VS.80).aspx
This causes the Form to intercept KeyDown events for any Controls in the Form. It can then pass on the event, or handle it, or both. Then handle the KeyDown event for the Form. If you've done MFC before, the rest should be easy.
-- HTH,
Kevin Spencer Microsoft MVP Ministry of Software Development http://unclechutney.blogspot.com
I just flew in from Chicago with a man with a wooden leg named Smith who shot an elephant in my pajamas. So I bit him.
"Wanjun Yu" <wa*******@hotm ail.comwrote in message news:%2****** **********@TK2M SFTNGP04.phx.gb l... Hi All, On my windows form, when the user hits the return key, I'll need to treat it as a tab key. i.e. when the user hits a return, the focus will move to the next item in the tab-order on the windows form.
I guess I can add a KeyDown event handler for each componet controls on the windows form, but that does not seem to be efficient.
Can I do it at the forms level? What i'm thinking is on FORMS if I can get this return event, I can send another tab key-down event. I know how to do this in MFC, but not in C#.
Thanks.
WJ
Hi John,
>I was about to post the same question when I found this thread. We have a custom app written in C# which does lots of strange things when our users hit the Enter key out of habit instead of the Tab key. The programmer claims it takes a lot of time and effort to modify the Windows forms to interpret the Return key to be a Tab key. I suspect he's not correct.
If there is already code in place to process complex key event logic it's
quite possible that it might be relatively complex to change the meaning of
the "enter" key in certain contexts.
Is the above suggestion the simplest way to cause the Enter key to always
act like a Tab key? Is this a lot of work to pull this off for a form?
In general, it's quite easy and the description in this thread is all that
most applications need to convert "enter" into "tab", so to speak.
One thing to consider is if the Form.AcceptButt on property is assigned. It
must be unassigned in order to change the behavior of the enter key unless the
key is handled before the Form gets a hold of it (I assume that handling the
Form.KeyPress event and setting KeyPreview to true should be enough, but I
haven't tested this myself).
--
Dave Sexton This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Gabriel B. |
last post by:
This is completely odd to me...
# Bind F1...F12 to <<TabKeys>>
self.tk.event_add( '<<TabKeys>>', # keys used to switch between the tabs
'<KeyPress-F1>','<KeyPress-F2>','<KeyPress-F3>','<KeyPress-F4>','<KeyPress-F5>',
'<KeyPress-F6>','<KeyPress-F7>','<KeyPress-F8>','<KeyPress-F9>','<KeyPress-F10>',
'<KeyPress-F11>','<KeyPress-F12>'
)
self.master.bind_all('<<TabKeys>>', self.__functionKeysPressed )
|
by: Pablo |
last post by:
I have a dilemma.
Currently, I may be passing standard text (strings of char) or binary of 1
to 'x' bytes long to a program for comparison with data previously written
to a file. The problem I'm having is I'm writing some routines which may
compare the data written on the disk to the some data being passed by the
programmer. And, the streams I'm passing may be shorter than the allowable
length limit (defined at runtime) but never...
|
by: chandy |
last post by:
Hi,
How can I treat multiple, contiguous records as one record?
i.e.,
tblData(
a varchar,
t datetime
)
|
by: Steven T. Hatton |
last post by:
"Reduced subclassing. Factory Method (107) often produces a hierarchy of
Creator classes that parallels the product class hierarchy. The Prototype
pattern lets you clone a prototype instead of asking a factory method to
make a new object. Hence you don't need a Creator class hierarchy at all.
This benefit applies primarily to languages like C++ that don't treat
classes as first-class objects. Languages that do, like Smalltalk and
Objective...
|
by: Jeevan |
last post by:
Hi,
I have some data which I am getting from a socket. I am currently
storing the
data in an array (so that future reading of the data will be fast as
it will
be in RAM instead of hard disk). Is there any way I can treat this
array as a file i.e. can I apply file operations (like fopen, fscanf
etc) on this array
without having to write the data into a physical file and then read
| |
by: Larry Lard |
last post by:
Recently we've been on a code quality drive and have eliminated all
compilation warnings from our code. To preserve this state, we've turned
'Treat warnings as errors' to 'All' in all our projects (and if only
this could be a solution level setting!).
However, we've now found that warnings produced by Code Analysis DO NOT
get treated as errors even with this flag set - it looks like this is
because the Code Analysis happens after the...
|
by: helraizer1 |
last post by:
Me again :D You're going to be sick of me soon. =P
I found the GifEncoder class on phpclasses, which creates an animated gif image from frames and echos it to the browser to show; can also save it as an image with .gif extension.
The only problem is that I need to add the animated gif onto another image (with imagecopymerge), however the gif image that is returned by this code in an object.
Here is the code:
GifEncoder.Class.php
|
by: Ken Snyder |
last post by:
hi ng,
reading a file line by line is no big match, but
i would like to read them and convert them to
string as if they where given like command
line args so that i can preprocess them and hand
them over to my real main. how can i do that?
I will write the command line args into a file and
read them from there as if they were given from
the command line. can you give me a short example
|
by: Craig Buchanan |
last post by:
I would like to monitor a POP3 mailbox with multiple clients. However, I want
to ensure that each message is processed by only one client. In essence, I
would like to treat a POP3 mailbox like a queue.
From what I've read thus far, atomic message access (if this is the right term)
isn't a native feature of the POP3 protocol. Am I mistaken?
My approach thus far, is to have one thread connect to the mailbox periodically,
look for new...
|
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...
|
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...
| |
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,...
|
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...
|
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();...
|
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...
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |