473,387 Members | 1,516 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,387 software developers and data experts.

keycode passes to next control

Hi group,

I want to verify if my problem also happens with other people,
place a radiobutton, two textboxes, and a button on a form then copy paste
this code run the prog and press enter on the button, then just click the
button and see the difference (where the focus ends)

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles _ Button1.Click
If RadioButton1.Checked = False Then
TextBox1.Focus()
Exit Sub
End If
End Sub

Private Sub TextBox1_KeyUp(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs) _ Handles TextBox1.KeyUp
If e.KeyCode = Keys.Enter Then
TextBox2.Focus()
End If
End Sub

I think this is expected behavior because the keyevent has to end somewhere
but because I call txt.focus and exit sub in the button_click event the
keyevent gets handled in the txt.keyup event but I don't want this to
happen. I want the same result as if I would click the button.

Greetz Peter
Nov 21 '05 #1
2 1326
Peter,
Look at setting the TabIndex property of each ctl to give the control
navigation order.

Serge O.

"Peter Proost" <pp*****@nospam.hotmail.com> wrote in message
news:u4**************@tk2msftngp13.phx.gbl...
Hi group,

I want to verify if my problem also happens with other people,
place a radiobutton, two textboxes, and a button on a form then copy paste
this code run the prog and press enter on the button, then just click the
button and see the difference (where the focus ends)

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles _ Button1.Click
If RadioButton1.Checked = False Then
TextBox1.Focus()
Exit Sub
End If
End Sub

Private Sub TextBox1_KeyUp(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs) _ Handles TextBox1.KeyUp
If e.KeyCode = Keys.Enter Then
TextBox2.Focus()
End If
End Sub

I think this is expected behavior because the keyevent has to end
somewhere
but because I call txt.focus and exit sub in the button_click event the
keyevent gets handled in the txt.keyup event but I don't want this to
happen. I want the same result as if I would click the button.

Greetz Peter

Nov 21 '05 #2
Hi,

I know the tabindex property, but I'm not using the tabkey. I need the enter
key, but never mind the question because the keyup just ain't going to work
for this

Greetz Peter

"S. Olivier" <sd***@hotmail.com> schreef in bericht
news:eE**************@TK2MSFTNGP10.phx.gbl...
Peter,
Look at setting the TabIndex property of each ctl to give the control
navigation order.

Serge O.

"Peter Proost" <pp*****@nospam.hotmail.com> wrote in message
news:u4**************@tk2msftngp13.phx.gbl...
Hi group,

I want to verify if my problem also happens with other people,
place a radiobutton, two textboxes, and a button on a form then copy paste this code run the prog and press enter on the button, then just click the button and see the difference (where the focus ends)

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles _ Button1.Click
If RadioButton1.Checked = False Then
TextBox1.Focus()
Exit Sub
End If
End Sub

Private Sub TextBox1_KeyUp(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs) _ Handles TextBox1.KeyUp
If e.KeyCode = Keys.Enter Then
TextBox2.Focus()
End If
End Sub

I think this is expected behavior because the keyevent has to end
somewhere
but because I call txt.focus and exit sub in the button_click event the
keyevent gets handled in the txt.keyup event but I don't want this to
happen. I want the same result as if I would click the button.

Greetz Peter


Nov 21 '05 #3

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

Similar topics

6
by: Z | last post by:
I have sub-classed the TextBox. In its OnKeyDown event I can intercept key strokes, examine them, etc. When I get a certain keycode (e.g., 'A') I want to change it to another unicode key from a...
17
by: Julia Briggs | last post by:
Are there any gotchas using if (event.keyCode==8)? I understand that to represent backspace, but it doesn't work. I am running Windows XP, using a typical keyboard - but no luck in detecting...
1
by: Perttu Pulkkinen | last post by:
I have different functions that receive window.event as parameter. Functions are used like this: <input type="text" id="x" onkeypress="return onKeyCurrencyCheck(ev, 'x')" onblur...
6
by: rich_poppleton | last post by:
Help.... I've got a textarea where people type in a description. However for certain reasons we need to stop them typing !$*^ . I have a solution this which works fine in IE: function...
4
by: Thomas Christensen | last post by:
I'm trying to figure out what key the user pressed using a Danish keyboard layout. charCodeAt returns the correct number, but event.keyCode returns a wrong number, when using one of the keys that...
2
by: melanieab | last post by:
Hi, Just checking to see if there's anything I can possibly do to allow for the recognition of the Tab key being pressed. On the KeyDown event I've tried: if (e.KeyCode == Keys.Tab), if...
3
by: Pugi! | last post by:
I got this (piece of) script from 'DHTML Utopia - Modern Webdesign - Using Javascript & DOM'. function aKeyWasPressed(e) { if (window.event) { var key = window.event.keyCode; } else { var key...
5
by: WilliamRLinden | last post by:
Hi world! we are pretty new to JavaScript and have been struggling for now 2 days on this problem ... We would appreciate mercy if anyone can give us some. Basically we are trying to simulate...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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,...

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.