Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Clearing arrays in vb.net 1

Status
Not open for further replies.

morg27

MIS
Feb 4, 2002
16
US
I used a panel on my form to create an array of checkboxes upon loading the form. When a user checks them I have a sub procedure that shows the number of empty checkboxes and full checkboxes in textboxes. How do I clear all of the checkboxes when the user chooses the clear checkboxes menu item.

Private Sub mmuSeatsClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mmuSeatsClear.Click
Call clearSeats()
End Sub

Private Sub clearSeats()
'This is where I want the code to clear the checkboxes
txtFull.Text = Full.ToString()
txtEmpty.Text = Empty.ToString()

End Sub
 
You can loop through all the checkboxes on the form.
Let me know if you need me to comment this code.



you call the sub like this

ClearChildText(Me.Controls)


Private Sub ClearChildText(ByVal contin As Control.ControlCollection)

Dim foundcontrol As Control


For Each foundcontrol In contin
If foundcontrol.GetType.ToString = "System.Windows.Forms.CheckBox" Then
CType(foundcontrol, CheckBox).Checked = False
End If

If foundcontrol.Controls.Count <> 0 Then
ClearChildText(foundcontrol.Controls)
End If
Next foundcontrol

End Sub

DotNetDoc
M.C.S.D.
---------------------------------------

Tell me and I forget. Show me and I remember. Involve me and I understand.
- Anonymous Chinese Proverb

-----------------------------------

If you can't explain it simply, you don't understand it well enough.
- A. Einstein





 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top