Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / July 2006

Tip: Looking for answers? Try searching our database.

Loop through controls

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Inga2005 - 18 Jul 2006 12:47 GMT
I have a winform with a number of user controls. On of the control is a
tab control which contains a number of pages where each page has
textboxes and other controls on it. I would like to loop through all
the texboxes on one of the tab pages and empty each and every one of
them. However, I only manage to loop through the separate tab pages and
not their content. Any ideas?
/erik
JezB - 18 Jul 2006 12:48 GMT
You need a recursive iteration. The form has a Controls collection, but
certain controls may also have their own Controls collection.

>I have a winform with a number of user controls. On of the control is a
> tab control which contains a number of pages where each page has
[quoted text clipped - 3 lines]
> not their content. Any ideas?
> /erik
Pritcham - 18 Jul 2006 12:56 GMT
Hi

Something like the following should do:

   Private Sub ClearControls(ByVal caller As Object, ByVal lock As
Boolean)
       Dim ctl As Control
       For Each ctl In caller.Controls
           If ctl.HasChildren Then
               ClearControls(ctl, lock)
           End If
           If TypeOf ctl Is Windows.Forms.TextBox Then
               ctl.Text = String.Empty
           End If
       Next
   End Sub

Hope that helps

Martin

> I have a winform with a number of user controls. On of the control is a
> tab control which contains a number of pages where each page has
[quoted text clipped - 3 lines]
> not their content. Any ideas?
> /erik

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.