Results 1 to 8 of 8

Thread: Adding Key Events on a Label

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2004
    Posts
    20

    Adding Key Events on a Label

    I don't see the key events in the public events for the label, but I really need those.

    Is it possible to do it?

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083

    Re: Adding Key Events on a Label

    Yes , you could inherit the Label class and add that event .

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jul 2004
    Posts
    20

    Re: Adding Key Events on a Label

    Extending the label class? sorry i'm kinda newbie.

    thx

  4. #4
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Then read up about events and delegates . Google it

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Jul 2004
    Posts
    20

    Re: Adding Key Events on a Label

    I have, but what I've found is about custom events, involving data and other stuff (I read the examples in .net framework doc etc -- the alarm etc) but it never mentions how to add an "existing event" to a existing control.

    Thats what I got a bit unclear.

  6. #6
    Addicted Member
    Join Date
    Jun 2003
    Location
    Birmingham, AL
    Posts
    188

    Re: Adding Key Events on a Label

    Like "key up" & "key down"? Wouldn't the control have to have focus in order to detect that.

  7. #7
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083

    Re: Adding Key Events on a Label

    Extending the existing Label class ,I think, won't work . You probably need to build custom control . It doesn't derive from or combine existing controls. It's a lot of hassle since you have to implement all the other events,methods,and properties .The base class that you would work with is Control which I guess has the Keyboard events .

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Jul 2004
    Posts
    20

    Re: Adding Key Events on a Label

    Yeah its a lot of work... I think the best solution is to save which label was "clicked/selected" last and then make one big event handler to process the key events for all the controls in my form, then fire up whatever I wan't to do.

    Speaking of which, where can I see which controls get focused by default? (i.e when you click on it or select it using tab -- does most controls work that way?)

    If thats the case, is it possible to "propagate" the key event to its parent form?

    You see, I need to make kinda like a modal row of labels, it needs to work kinda like a tabbed window, where a tab always need to be selected, meaning that the key events (shortcuts) are in fact global -- like in a menu, so focus isn't important.

    Anyways this is certanly not the practical solution but it can work ok with "less thinking"

    If anyone has a better idea please let me know.

    thanks for your help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width