שתף באמצעות


pressing enter key with a textbox

Question

Tuesday, September 21, 2010 11:36 AM

Hiya folks

im struggling to get my form to work properly,  when the user enter the details into the textbox and they press enter i want a button to activate.  Ive tried

sendkeys.send(Enter)  cant remeber the exact code

then some event handler on the Send.keys help section on windows.

Am i doing something wrong.  can anyone help? Scooby scooby scoobedadoo.

 

Rimlesskid

Thanks for the help. What not to put on an Employee evaluation: This employee has hit rock bottom and shows signs of starting to dig.

All replies (4)

Tuesday, September 21, 2010 12:13 PM ✅Answered | 1 vote

In the WinForms designer, select the form. It has a property called AcceptButton, where you can select your button from a dropdown. This button will be clicked automatically when the user presses enter.

Mark the best replies as answers!


Tuesday, September 21, 2010 1:42 PM ✅Answered

Try the KeyUp event of the TextBox...

Here's what I use to implement the Enter Key press event for the txtPIDSearch textbox, which runs the function SelectParcelByTextBoxVal() when the enter key is pressed:

 

Private Sub txtPIDSearch_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtPIDSearch.KeyUp
    Try
      If e.KeyValue = Keys.Enter Then
        SelectParcelByTextBoxVal()
      End If
    Catch ex As Exception
      MsgBox(ex.ToString)
    End Try
  End Sub

 

 

 

James Crandall ~ http://javitechnologies.com Spatial Database Solutions


Thursday, September 23, 2010 8:22 AM

Thanks folks, thats a huge help.

Thanks for the help. What not to put on an Employee evaluation: This employee has hit rock bottom and shows signs of starting to dig.


Thursday, April 2, 2015 4:17 AM

Thank you so much Daniel!