VB.Net Control Checkbox Association

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
 
G

Guest

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top