user3806216
user3806216

Reputation: 17

Event trigger on "ENTER" key press

I have designed a Window_Form in which I want to give a functionality such that whenever a user press "Enter" Button in ComboBox, a query is executed.

Upvotes: 0

Views: 7660

Answers (2)

deepak jadhav
deepak jadhav

Reputation: 1

private void txtShNumber_KeyDown(object sender, KeyEventArgs e)
{
    if (e.Key == Key.Enter && txtShNumber.Text.Trim() != "")
    {
          /////your code
    }
}  

it will work for wpf and C# applications

Upvotes: 0

Jande
Jande

Reputation: 1705

Try this:

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

        If e.KeyCode = Keys.Enter Then

            MsgBox("Here you can execute query")

        End If

    End Sub

Upvotes: 1

Related Questions