trapping enter key on Windows form (send keys option)

  • Thread starter Thread starter Sanjeev K B
  • Start date Start date
S

Sanjeev K B

Hi,

I am working on a windows form which facilitates Data Entry operation. The
form contains a variety of controls including textboxes, comboboxes,
RichTextBoxes and Datagrid.
I am looking for a solution which would help the user in moving around the
form when he presses the enter button (tab operation).

Could anyone please help me out in this matter. How can i trap enter key
press and then send key tab??

Thanks and Regards,
Sanjeev K.B.
 
Hi,

Set the forms keypreview property to true so all keydown events are
sent to the form before the control.

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

If e.KeyCode = Keys.Enter Then

SelectNextControl(ActiveControl, True, True, True, True)

End If

End Sub



Ken
 
Hi Ken,

thanks a lot for your help. i really appreciate this.

Thanks again
Sanjeev K.B.
 

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

Back
Top