|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Assign a value to groupbox from a radiobutton contained in groupboHello,
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 "Rich" <R***@discussions.microsoft.com> schrieb: Add a common event handler to all the radio buttons which belong to a group:> 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) \\\ 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 /// -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/> Thank you very much. That was just what I was looking for.
Rich Show quoteHide quote "Herfried K. Wagner [MVP]" wrote: > "Rich" <R***@discussions.microsoft.com> schrieb: > > 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 > /// > > -- > M S Herfried K. Wagner > M V P <URL:http://dotnet.mvps.org/> > V B <URL:http://classicvb.org/petition/> > > |
|||||||||||||||||||||||