Help with radio buttons and text
I'm a beginner so please take it easy on me. I was wondering what the code is for the text of ANY selected radio button to appear in the multiline textbox that is already set up. Is that at all possible? If so, can you do the same for check boxes?
Thanks
Re: Help with radio buttons and text
There's nothing that will automatically get the RadioButton that is currently checked from a group. You just have to test the Checked property of each one in the group until you find one that's True. You can then get the Text of that RadioButton and call AppendText on the TextBox.
The old-school way would be to use an If...ElseIf block to test each RadioButton. Assuming .NET 3.5 or later, you could use LINQ instead, e.g.
vb.net Code:
Dim radioButtons = New RadioButton() {Me.RadioButton1, Me.RadioButton2, Me.RadioButton3}
Dim checkedRadioButton = radioButtons.SingleOrDefault(Function(rb) rb.Checked)
If you know for a fact that one of the RadioButtons will be checked then you can use Single instead of SingleOrDefault and 'checkedRadioButton' will never be Nothing.