if keydown equal to F5 then ....

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hanif
    New Member
    • Sep 2007
    • 1

    if keydown equal to F5 then ....

    private void tbProjectID_Key Down(object sender, KeyEventArgs e)
    {
    if (e.KeyCode ==Keys.F5)
    {
    f_cariproject carip = new f_cariproject() ;
    carip.Show();
    }
    }


    =====
    Igot trouble whith statement, can u help me couse I am new in C#
  • HaLo2FrEeEk
    Contributor
    • Feb 2007
    • 404

    #2
    First off, code tags, always put your code in code tags.

    Secondly, try to explain in a little more detail exactly what the problem you're having is. From the looks of it you want to capture the keyboard event and if the key pressed was F5 you want to show a new form. To that end your code looks fine. Remember that, by default, keyboard handlers in C# won' be captured unless the form has focus, meaning that if you've got that program open but another window has focus when you press F5, your program won't see that. There is a class called GlobalKeyboardH ook that you should look into if this is your problem.

    Comment

    • Sfreak
      New Member
      • Mar 2010
      • 64

      #3
      And dont forget to set the KeyPreview = true in your form control.

      Comment

      Working...