VB.Net Control Checkbox Association

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a mnuNew_Click event that I am attempting to reset a forms textbox,
checkbox and picturebox's. The attached code is an attempt to loop through
the forms controls and reset them but I cannot find any option within the
controls class to set the properties for the checkbox and the picture box.

Dim tabCtl as TabControl
Dim tabPg as TabPage
Dim ctl as Control

tabCtl = Me.tabName

For Each tabPg In tabCtl.TabPages
For Each ctl In tabPg.Controls
If TypeOf(ctl) Is TextBox Then
ctl.Text = vbNullString 'Code works
ElseIf TypeOf(ctl) Is CheckBox Then
'ctl. ??? '=vbUnchecked
'.Checked & .Value are not options
ElseIf TypeOf(ctl) Is PictureBox Then
'ctl. ??? '= Nothing
'.Value is not an option???
End If
Next
Next

Any assistance would be greatly appreciated. Thanks
 
Through countless hours of searching in google, I stumbled across the answer:

ElseIf TypeOf(ctl) Is CheckBox Then
DirectCast(ctl, CheckBox).Checked = False
ElseIf TypeOf(ctl) Is PictureBox Then
DirectCast(ctl, PictureBox).image = Nothing

Oh my gosh! Where did this function come from and why is it necessary?
 
Back
Top