Answered by:
Group box radio buttons

Question
-
Hi There,
I am trying to get 2 group boxes with radio buttons. I would like to check a radio button in group box 1 and have a corresponding radio button in group set 2 get automatically checked based on what I check in group box1. I am trying to do this in VB. If anyone know how let me know. Also, code to do this would be greatly appreciated.
Thanks,
Bill
Wednesday, February 24, 2010 4:38 PM
Answers
-
I was curious if this would go and it did
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load RadioButton1.DataBindings.Add("Checked", RadioButton3, "Checked") RadioButton2.DataBindings.Add("Checked", RadioButton4, "Checked") RadioButton3.DataBindings.Add("Checked", RadioButton1, "Checked") RadioButton4.DataBindings.Add("Checked", RadioButton2, "Checked") End Sub
Success
Cor- Proposed as answer by DiegoCattaruzza Wednesday, February 24, 2010 6:54 PM
- Marked as answer by Jeff Shan Thursday, March 4, 2010 1:33 AM
Wednesday, February 24, 2010 5:25 PM -
You can tie them together like this . You need to add and remove the handlers to avoid an endless loop .
Private Sub RadioButton1_CheckedChanged( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles RadioButton1.CheckedChanged
RemoveHandler RadioButton4.CheckedChanged, AddressOf RadioButton4_CheckedChanged
RadioButton4.Checked = RadioButton1.Checked
AddHandler RadioButton4.CheckedChanged, AddressOf RadioButton4_CheckedChanged
End Sub
Private Sub RadioButton4_CheckedChanged( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles RadioButton4.CheckedChanged
RemoveHandler RadioButton1.CheckedChanged, AddressOf RadioButton1_CheckedChanged
RadioButton1.Checked = RadioButton4.Checked
AddHandler RadioButton1.CheckedChanged, AddressOf RadioButton1_CheckedChanged
End Sub
Coding4fun Be a good forum member mark posts that contain the answers to your questions or those that are helpful
Please format the code in your posts with thebutton . Makes it easier to read . Or use the Forum Code Formatter by JohnWein http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/bf977a14-d9d4-4e84-9784-bf76b9e23261
- Marked as answer by Jeff Shan Thursday, March 4, 2010 1:33 AM
Wednesday, February 24, 2010 4:52 PM -
You would just handle the CheckChanged event of each radio button, and in that event if the radiobutton's .checked property is true, then set the cooresponding other radio buttons .checked property to true.
Matt Kleinwaks - MSMVP MSDN Forums Moderator - www.zerosandtheone.com- Marked as answer by Jeff Shan Thursday, March 4, 2010 1:33 AM
Wednesday, February 24, 2010 4:53 PM -
Use Property Binding to connect two control properties together.
http://www.vbdotnet.com.nu/linked_control_properties.html
For your case, you will link the checked property of one radio button to the checked property of the other radio buttin by binding the checked property of each radiobutton to the same settings variable.
- Marked as answer by Jeff Shan Thursday, March 4, 2010 1:33 AM
Thursday, February 25, 2010 1:37 AM
All replies
-
You can tie them together like this . You need to add and remove the handlers to avoid an endless loop .
Private Sub RadioButton1_CheckedChanged( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles RadioButton1.CheckedChanged
RemoveHandler RadioButton4.CheckedChanged, AddressOf RadioButton4_CheckedChanged
RadioButton4.Checked = RadioButton1.Checked
AddHandler RadioButton4.CheckedChanged, AddressOf RadioButton4_CheckedChanged
End Sub
Private Sub RadioButton4_CheckedChanged( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles RadioButton4.CheckedChanged
RemoveHandler RadioButton1.CheckedChanged, AddressOf RadioButton1_CheckedChanged
RadioButton1.Checked = RadioButton4.Checked
AddHandler RadioButton1.CheckedChanged, AddressOf RadioButton1_CheckedChanged
End Sub
Coding4fun Be a good forum member mark posts that contain the answers to your questions or those that are helpful
Please format the code in your posts with thebutton . Makes it easier to read . Or use the Forum Code Formatter by JohnWein http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/bf977a14-d9d4-4e84-9784-bf76b9e23261
- Marked as answer by Jeff Shan Thursday, March 4, 2010 1:33 AM
Wednesday, February 24, 2010 4:52 PM -
You would just handle the CheckChanged event of each radio button, and in that event if the radiobutton's .checked property is true, then set the cooresponding other radio buttons .checked property to true.
Matt Kleinwaks - MSMVP MSDN Forums Moderator - www.zerosandtheone.com- Marked as answer by Jeff Shan Thursday, March 4, 2010 1:33 AM
Wednesday, February 24, 2010 4:53 PM -
I was curious if this would go and it did
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load RadioButton1.DataBindings.Add("Checked", RadioButton3, "Checked") RadioButton2.DataBindings.Add("Checked", RadioButton4, "Checked") RadioButton3.DataBindings.Add("Checked", RadioButton1, "Checked") RadioButton4.DataBindings.Add("Checked", RadioButton2, "Checked") End Sub
Success
Cor- Proposed as answer by DiegoCattaruzza Wednesday, February 24, 2010 6:54 PM
- Marked as answer by Jeff Shan Thursday, March 4, 2010 1:33 AM
Wednesday, February 24, 2010 5:25 PM -
Use Property Binding to connect two control properties together.
http://www.vbdotnet.com.nu/linked_control_properties.html
For your case, you will link the checked property of one radio button to the checked property of the other radio buttin by binding the checked property of each radiobutton to the same settings variable.
- Marked as answer by Jeff Shan Thursday, March 4, 2010 1:33 AM
Thursday, February 25, 2010 1:37 AM