keycode passes to next control

P

Peter Proost

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
 
S

S. Olivier

Peter,
Look at setting the TabIndex property of each ctl to give the control
navigation order.

Serge O.
 
P

Peter Proost

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top