Assign a value to groupbox from a radiobutton contained in groupbo

G

Guest

Hello,

Is it possible to assign a value to a groupbox by selecting a radiobutton
contained in the groupbox?

Say you assign a value of 1 to radbtn1, 2 for radbtn2, 3 for radbtn3 all
contained in grpBox. You click radbtn1.

Console.writeline(grpBox.Value.ToString)

Is there a way to do something like this? (VB2005)

Thanks,
Rich
 
H

Herfried K. Wagner [MVP]

Rich said:
Is it possible to assign a value to a groupbox by selecting a radiobutton
contained in the groupbox?

Say you assign a value of 1 to radbtn1, 2 for radbtn2, 3 for radbtn3 all
contained in grpBox. You click radbtn1.

Console.writeline(grpBox.Value.ToString)

Is there a way to do something like this? (VB2005)

Add a common event handler to all the radio buttons which belong to a group:

\\\
Private m_Group1SelectedRadioButton As RadioButton

Private Sub RadioButtonGroup1_CheckedChanged( _
ByVal sender As Object, _
ByVal e As EventArgs _
) Handles _
RadioButton1.CheckedChanged, _
RadioButton2.CheckedChanged, _
RadioButton3.CheckedChanged

Dim SourceControl As RadioButton = DirectCast(sender, RadioButton)
If SourceControl.Checked Then
m_Group1SelectedRadioButton = SourceControl
End If
End Sub
///
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top