|
-
May 27th, 2002, 12:17 PM
#1
Thread Starter
New Member
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.
-
May 27th, 2002, 12:24 PM
#2
Member
whatchya mean? like ALT+C controls 5 radio buttons at once? use arrays?
Visual Basic 6.0, Visual Basic .NET, C#, C++, ASM, HTML
-
May 27th, 2002, 12:42 PM
#3
Thread Starter
New Member
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.
-
May 27th, 2002, 12:45 PM
#4
Member
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
-
May 27th, 2002, 01:27 PM
#5
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.
-
May 27th, 2002, 01:30 PM
#6
Member
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
-
May 27th, 2002, 01:37 PM
#7
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.
-
May 27th, 2002, 01:44 PM
#8
Member
Visual Basic 6.0, Visual Basic .NET, C#, C++, ASM, HTML
-
May 27th, 2002, 02:29 PM
#9
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
-
May 28th, 2002, 12:40 PM
#10
Thread Starter
New Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|