You must Sign In to post a response.
  • Category: Windows

    How to get KeyDown event for a Label control

    Hi,

    Please let me know how i can get KeyDown event for Label control.
    Normally label control doesn't have KeyDown event. Is there any way to get this event?

    Thanks,
  • #620549
    hi

    can you tell me what you are going to do with this keydown event for lablel?

  • #620557
    May be use can use Previewkeydown event :


    private void label1_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
    {
    switch (e.KeyCode)
    {
    case Keys.Down:
    case Keys.Up:
    MessageBox.Show("Hi");
    break;
    }
    }

    private void label1_MouseClick(object sender, MouseEventArgs e)
    {
    label1.Focus();
    }

  • #621248
    Dear You can make a textbox look alike label and proceed and complicated codes make future references to the code almost impossible that's my view. regards Dn
    Deepak Negi (Dn)
    PG-DAC, CDAC 2014(3rd Position at Noida Centre)
    M. Sc. (C.S.), B.C.A.
    ASP.NET with C# and MVC 4:: Version 4.5
    deepaknegi1884@gmail.com
    +91-90240-60630


  • This thread is locked for new responses. Please post your comments and questions as a separate thread.
    If required, refer to the URL of this page in your new post.