Nirmal
Nirmal

Reputation:

key down in .net

How to validate iscontrolkeys in textbox keydown event in .net?

Upvotes: 0

Views: 183

Answers (2)

Russ Cam
Russ Cam

Reputation: 125488

in C#,

       private void textBox1_KeyDown(object sender, KeyEventArgs e)
    {
        if (e.KeyCode == Keys.ControlKey)
        {
            //Do some work
        }
    }

in VB.NET,

       Private  Sub textBox1_KeyDown(ByVal sender As Object, ByVal e As KeyEventArgs)
            If e.KeyCode = Keys.ControlKey Then
                'Do some work'
            End If
       End Sub

Upvotes: 0

penderi
penderi

Reputation: 9073

This msdn page should do the trick - check the keypresseventsargs returned in the keypress or this keydown page should allow you to query the control keys (using the relevant .Net enum)

Upvotes: 1

Related Questions