Sunday, February 13, 2011

key down in .net

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

  • Hi,

    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)

    From ip
  • 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
    
    From Russ Cam

0 comments:

Post a Comment