I am using VB.Net to create one radiobutton for each line in a text file.
SFLines is the number of lines in the text files. SFInfo is an array that is created using a Split on each line. The code works fine and my group populates with all the radio buttons. The issue is with the .Checked of the radio buttons created. Because the radio buttons are created in the forms on load event I cannot add code that references the radio button. VB.Net states that the Name RadioButtonX is not defined.Code:For i = 0 To SFLines.Length - 1 SRadioButton = New RadioButton With SRadioButton .Text = SFInfo(i, 1) & ", " & SFInfo(i, 0) .Location = New Point(10, ((i + 1) * 17)) .Size = New Size(180, 17) .Name = "RadioButton" & i Me.grpSRadio.Controls.Add(SRadioButton) End With Next
Here is what I tried to do:
This does not work.Code:Private Sub btnSelect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSelect.Click Dim i Dim SRadioButton As New RadioButton For i = 0 To SFLines.Length - 1 SRadioButton.Name = "RadioButton" & i If SRadioButton.Checked = True Then MsgBox(SRadioButton.Text) End If Next End Sub
I need a Select button that will display some info about the array element based on the radio button selected.
Any help would be greatly appreciated.


Reply With Quote
