hi.
i am developing a simple vb.net application. i have three forms in my app. the first form has 2 radio buttons from which i need to select one. based on the selection made in my next form a combobox ll be populated.so far so good.there is a back button on my 2nd form which when clicked redirects me to the first form. here when i select the next radio button the combo box in the next form does not populate accordingly. it still holds the old values.

i hope my question is clear.

this is the code i have in the first form.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim frm As Form2
        frm = New Form2()
        If RadioButton1.Checked Then
            passedtext = RadioButton1.Text
        ElseIf RadioButton2.Checked Then
            passedtext = RadioButton2.Text
        End If
        Me.Hide()
        frm.Show()
    End Sub

this is the code i have in the second form

Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        selectionstr = Form1.passedtext
        If String.Compare(selectionstr, "UNDER GRADUATE", True) = 0 Then
            'Dim obj As New Form1
            'obj.passedtext = Form1.RadioButton1.Text
            'If Form1.RadioButton1.Checked Then
            ComboBox1.Items.Clear()
            ComboBox1.Items.AddRange(New String() {"op1","op2"})
        ElseIf String.Compare(selectionstr, "POST GRADUATE", True) = 0 Then
            'ElseIf Form1.RadioButton2.Checked Then
            ComboBox1.Items.Clear()
            ComboBox1.Items.AddRange(New String() {"opt1","opt2"})
        End If
    End Sub

DO NOT use the form load event for populating control (on form2), becuase it will rise only 1 time (only when form opened).
Better create a new method on form2, and call it each time you want to pass some data from form1 to form2. This way you can execute it when ever you want.

DO NOT use the form load event for populating control (on form2), becuase it will rise only 1 time (only when form opened).
Better create a new method on form2, and call it each time you want to pass some data from form1 to form2. This way you can execute it when ever you want.

Mitja
thank u so much. i did as u told.i created a new method in form 2 and called it on the first form in a button click event given above. yet i get the same fault. it is not populating according to my selection.

This article has been dead for over six months. Start a new discussion instead.