How to clear a RadioButton

filleke

New member
Joined
Jan 18, 2006
Messages
4
Location
Belgium
Programming Experience
1-3
Hello,

I created a function to clear any fields in my forms but I also want to uncheck the radiobuttons in the form. I can't apparently use the rb.checked property.

Any suggestions?

VB.NET:
Public Sub ClearForms(ByVal frm As Form)
        Dim ctrl As Control
        For Each ctrl In frm.Controls
            If TypeOf ctrl Is TextBox OrElse TypeOf ctrl Is ComboBox _
           Then
                ctrl.Text = ""
            End If
            If TypeOf ctrl Is RadioButton Then
                ?????????
            End If
        Next
    End Sub
 
VB.NET:
[COLOR=black][FONT=Courier New][COLOR=blue]If[/COLOR] [COLOR=blue]TypeOf[/COLOR] ctrl [COLOR=blue]Is[/COLOR] RadioButton [COLOR=blue]Then[/COLOR]
[COLOR=blue]    DirectCast[/COLOR](control, RadioButton).Checked = [COLOR=blue]False[/COLOR]
[COLOR=blue]End[/COLOR] [COLOR=blue]If[/COLOR]
[/FONT][/COLOR]

Other way is: code the initial settings you want for all controls in a method Clear (or Reset, or Init,...). Call this method from your Load event handler.
If you need it elsewhere: just call the method again.
 
Back
Top