Results 1 to 9 of 9

Thread: A Question

  1. #1

    Thread Starter
    Frenzied Member markman's Avatar
    Join Date
    Nov 2000
    Location
    Florida.
    Posts
    1,197

    A Question

    I usually dont title things by "Question" or something of the dort, but no one was looking at this and im sure its common knowledge. The original title was UserControls and AccessKeys.

    I have a Label in a usercontrol that has a caption of "&Hello". When I hit alt+H, I want the usercontrol to fire a msgbox. How would I do that?
    Last edited by markman; Nov 1st, 2001 at 03:40 PM.
    retired member. Thanks for everything

  2. #2

    Thread Starter
    Frenzied Member markman's Avatar
    Join Date
    Nov 2000
    Location
    Florida.
    Posts
    1,197
    :bump:
    retired member. Thanks for everything

  3. #3
    Frenzied Member nishantp's Avatar
    Join Date
    Jan 2001
    Location
    Where you least expect me to be
    Posts
    1,375
    what does it have to do with a label?
    VB Code:
    1. Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    2.     If KeyCode = vbKeyH And ((Shift And vbAltMask) > 0) Then
    3.         MsgBox "Alt-H was pressed"
    4.     End If
    5. End Sub
    You just proved that sig advertisements work.

  4. #4
    Frenzied Member nishantp's Avatar
    Join Date
    Jan 2001
    Location
    Where you least expect me to be
    Posts
    1,375
    Oops sorry i forgot its for a UserControl...but the code should be exactly the same, just a different sub name. Sorry.
    You just proved that sig advertisements work.

  5. #5

    Thread Starter
    Frenzied Member markman's Avatar
    Join Date
    Nov 2000
    Location
    Florida.
    Posts
    1,197
    But that would only work if it has focus...
    Id like this to happen even when another totally different control has focus.
    retired member. Thanks for everything

  6. #6
    hellswraith
    Guest
    Use the AccessKeys property and the AccessKeyPress event of the UserControl.

    Put the letter(s) in the AccessKeys property, and put your code int the AccessKeyPress event.

  7. #7

    Thread Starter
    Frenzied Member markman's Avatar
    Join Date
    Nov 2000
    Location
    Florida.
    Posts
    1,197
    Do you have any examples for that? I can't get it to work.
    retired member. Thanks for everything

  8. #8
    hellswraith
    Guest
    The ForwardFocus property of your usercontrol needs to be False, if it is true, it will send the focus away. Also, if you have constituent controls that can receive focus, it receives the focus, otherwise the control will receive focus.

    I have no examples, just something that is in my head from those damn MCSD tests. I refered back to the book, and that's what it says.

    To assign the access keys, you need to put the letter into the property, not ALT, just the letter.

  9. #9

    Thread Starter
    Frenzied Member markman's Avatar
    Join Date
    Nov 2000
    Location
    Florida.
    Posts
    1,197
    Originally posted by hellswraith
    The ForwardFocus property of your usercontrol needs to be False, if it is true, it will send the focus away. Also, if you have constituent controls that can receive focus, it receives the focus, otherwise the control will receive focus.

    I have no examples, just something that is in my head from those damn MCSD tests. I refered back to the book, and that's what it says.

    To assign the access keys, you need to put the letter into the property, not ALT, just the letter.
    What do you mean by constituent? I am trying to get this to work on this code from psc.
    retired member. Thanks for everything

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