Results 1 to 10 of 10

Thread: Keyboard shortcut for radio buttons

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2002
    Posts
    6

    Keyboard shortcut for radio buttons

    How would you set up a single keyboard shortcut, e.g. ALT+C, to control a GroupBox control full of radio buttons?

    Using hidden labels (with text = "&C") for tab order is undesireable, because they can only go through the series once. What I'm looking for is a way for the user to be able to toggle through the selections over and over again, on that same shortcut.

    Thanks in advance.

  2. #2
    Member wej42's Avatar
    Join Date
    May 2002
    Location
    Rhode Island, USA
    Posts
    48
    whatchya mean? like ALT+C controls 5 radio buttons at once? use arrays?
    Visual Basic 6.0, Visual Basic .NET, C#, C++, ASM, HTML

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2002
    Posts
    6
    Yes. ALT+C once would take you from the first to the second button, ALT+C again would take you from the second to the third, etc. The fifth time you'd go from the fifth back to the first.

  4. #4
    Member wej42's Avatar
    Join Date
    May 2002
    Location
    Rhode Island, USA
    Posts
    48
    u would think this would be a simple task. lol
    Last edited by wej42; May 27th, 2002 at 01:00 PM.
    Visual Basic 6.0, Visual Basic .NET, C#, C++, ASM, HTML

  5. #5
    hellswraith
    Guest
    Make the first one an access key:

    ' Set the letter "P" as an access key.
    Button1.Text = "&Print"

    Then, in the OnFocus event (or something like that, haven't used VB.Net myself) include a static variable (integer). In that event increase it by one, then do a switch statement (select case) to set the focus to the appropriate control. Everytime the variable gets to the amount of the option boxes you want to scroll, set it back to 0 and start over.

    This is just an idea, not sure if you can get it to work.

  6. #6
    Member wej42's Avatar
    Join Date
    May 2002
    Location
    Rhode Island, USA
    Posts
    48
    i went to make an app 4 him that did that, and it dont work...
    no errors or anything, it just.. doesnt work
    Visual Basic 6.0, Visual Basic .NET, C#, C++, ASM, HTML

  7. #7
    hellswraith
    Guest
    Lets see the code... It will work, it may not be the best way to do it, but it will work if you did it like I said.

  8. #8
    Member wej42's Avatar
    Join Date
    May 2002
    Location
    Rhode Island, USA
    Posts
    48
    my code?
    Visual Basic 6.0, Visual Basic .NET, C#, C++, ASM, HTML

  9. #9
    hellswraith
    Guest
    you said you created a app for it, but it didn't work, where is the code from that?
    i went to make an app 4 him that did that, and it dont work...
    no errors or anything, it just.. doesnt work

  10. #10

    Thread Starter
    New Member
    Join Date
    May 2002
    Posts
    6
    Wouldn't that interfere with use of mouse / clicks instead of the keyboard shortcut? I tried to set your concept up around the keydown event instead, but couldn't get it to work:

    Dim intToggle as Integer
    intToggle = 1 ' defaults to RadioButtonA.checked = True

    Private Sub frmMain_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
    If e.Alt And (e.KeyCode = Keys.C) Then
    Select Case intToggle
    Case 1
    RadioButtonB.Checked = True
    Case 2
    RadioButtonC.Checked = True
    Case 3
    RadioButtonD.Checked = True
    Case 4
    RadioButtonE.Checked = True
    Case Else
    RadioButtonA.Checked = True
    intToggle = 0
    End Select
    intToggle += 1
    End If
    End Sub

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