Enter Key

  • Thread starter Thread starter Claudie Bouzy
  • Start date Start date
ugly sollution but it works (there are probably some ppl that want to kill
me for this ;p) if there are better wayslet me know

create a button set its border attributes so you can't c them and if you
want hide it behind another controll. Set the button as the acceptbutton of
the form and put code like this behind it.

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click

Select Case True

Case cboLijn.Focused

txtBegMeter.Focus()

txtBegMeter.SelectAll()

Case txtBegMeter.Focused

bevestigLijn()

Case cboProduct.Focused

txtColli.Focus()

txtColli.SelectAll()

Case txtColli.Focused

cboSchaal.Focus()

cboSchaal.SelectAll()

Case Else

End Select

End Sub
 
Turn "KeyPreview ON" for the form before your try this code:


Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown

If e.KeyCode = Keys.Enter Then
If Not ActiveControl Is Nothing Then
SendKeys.Send("{TAB}")
End If
End If

End Sub
 
this looks a lot better :)
do you know how to include a shift w that (for example shift+tab) ?

eric
 
To give Claudie the benefit, the servers have been a little slow, perhaps
they grew impatient when it hadn't appeared on the group, so firgured they
probably didn't send it right, or it got lost etc.... so posted again.

caused enough discussion. ;o)

Dan.


* "Claudie Bouzy said:
How do I set the enter key to move from one field to the
next field?

You don't need to post more than once.
 
I'm not all that sure with VB, (still getting my head around what it can,
and more importantly, can't allow you to do! ;o) ), but with C++ you can do
the same thing, but have another "if" test to check if the shift key is
currently down.

So you'd need some sort of

If ShiftIsDown And Keypress was W

type thing...

this looks a lot better :)
do you know how to include a shift w that (for example shift+tab) ?

eric
 
sorry i meanth in the sending part

like if you press insert the sub sends shift+tab to the form so the previous
control is selected

but this is sertainly usefull 2
 
tnx :)

i should have asked claudies question a few months ago instead of working
out my own hidden enter button ;p

eric
 
* "Daniel Bass said:
To give Claudie the benefit, the servers have been a little slow, perhaps
they grew impatient when it hadn't appeared on the group, so firgured they
probably didn't send it right, or it got lost etc.... so posted again.

Now the servers seem to be incredibly fast.
 
They do over the last week, which is great! =o)

Sick of that spam, who ever writes it, but perhaps more importantly, who in
the hell ever responds to it to make it worth their while sending it in the
first place?


* "Daniel Bass said:
To give Claudie the benefit, the servers have been a little slow, perhaps
they grew impatient when it hadn't appeared on the group, so firgured they
probably didn't send it right, or it got lost etc.... so posted again.

Now the servers seem to be incredibly fast.
 
Back
Top