kdgarris Member Licensed User Longtime User Oct 9, 2016 #1 I'm trying to figure out how to best make use of radiobuttons. I understand that all radiobuttons with the same parent will be in the same group in terms of only one being selected at a time. However, events don't seem to work in the way that I'd want or expect, and I'm not sure if there's a way to change that. Specifically, if I generate subs for these radiobuttons getting checked or unchecked, each one has its own sub. Ideally what I would like is to have one sub that is invoked if any of them are selected, and have a way within that sub to see which one is now checked. I think this would be much cleaner and more elegant. Is there a way to accomplish this? Thanks in advance for any advice for a newbie.
I'm trying to figure out how to best make use of radiobuttons. I understand that all radiobuttons with the same parent will be in the same group in terms of only one being selected at a time. However, events don't seem to work in the way that I'd want or expect, and I'm not sure if there's a way to change that. Specifically, if I generate subs for these radiobuttons getting checked or unchecked, each one has its own sub. Ideally what I would like is to have one sub that is invoked if any of them are selected, and have a way within that sub to see which one is now checked. I think this would be much cleaner and more elegant. Is there a way to accomplish this? Thanks in advance for any advice for a newbie.
derez Expert Licensed User Longtime User Oct 9, 2016 #2 Give the radiobuttons the same event name (you can give them different tags), hence one sub only for this event. Use the sender keyword to find the selected radiobutton and take action accordingly. Upvote 0
Give the radiobuttons the same event name (you can give them different tags), hence one sub only for this event. Use the sender keyword to find the selected radiobutton and take action accordingly.
Cableguy Expert Licensed User Longtime User Oct 10, 2016 #3 Also, if you need to know which one is the sender, use the tag property for each radio button. Then you can use something like: Code: Copy Dim myRButton as RadioButton = Sender If myRButton.tag = "xpto" then... Upvote 0
Also, if you need to know which one is the sender, use the tag property for each radio button. Then you can use something like: Code: Copy Dim myRButton as RadioButton = Sender If myRButton.tag = "xpto" then...