?
Solved

For Each control in TabPage

Posted on 2004-08-04
10
Medium Priority
?
328 Views
Last Modified: 2010-04-23
hi all!

        Dim n As CheckBox
        For Each n In fMain.tabReports.Controls
            n.Checked = False
        Next

        Dim n As CheckBox
        For Each n In fMain.tabReports.ControlCollection
            n.Checked = False
        Next

neither of these work... ideas?
0
Comment
Question by:Grunge
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 19

Expert Comment

by:Fahad Mukhtar
ID: 11715352
Dim c As CheckBox
        For Each c In fMain.tabReports.TabPages(1).Controls
            c.Checked = False
        Next
0
 
LVL 1

Author Comment

by:Grunge
ID: 11715889
that returns an "invalid cast"

.............i should mention that tabReports is a tabPage (one of serveral) on a tab control (tabAll)
0
 
LVL 1

Author Comment

by:Grunge
ID: 11715903
so i tried

        For Each n In fMain.tabAll.TabPages(1).Controls()
            n.Checked = False
        Next

no joy
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 4

Expert Comment

by:jrandallsexton
ID: 11716071
           Dim chk As New CheckBox
            Dim ctl As Control
            For Each ctl In TabPage1.Controls
                If ctl.GetType.ToString = chk.GetType.ToString Then
                    CType(ctl, CheckBox).Checked = True
                End If
            Next
0
 
LVL 14

Expert Comment

by:ptakja
ID: 11716095
That doesn't work because the Controls collection most likely has more than just checkboxes.  You need to test for that...


    For Each ctl As Control In fMain.tabReports.TabPages(1).Controls()
          Try
               Dim chk As CheckBox = CType(ctl, CheckBox)
               chk.Checked = False        ' If you make it this far, the control is a Checkbox
          Catch
               'Ignore invalid cast exception
          End try
    Next
0
 
LVL 11

Expert Comment

by:Babycorn-Starfish
ID: 11716103
Hi,

I tried something similar, although i omitted the tab page container and just called the tabpage direct.

 Dim myChk As CheckBox

For Each myChk In Me.TabPage1.Controls
      myCont.Checked = True        'used true for visual confirmation
Next

Any Joy?

BS
0
 
LVL 4

Assisted Solution

by:jrandallsexton
jrandallsexton earned 400 total points
ID: 11716126
Maybe I should add comments tot my post:

            Dim chk As New CheckBox 'used for type conparison
            Dim ctl As Control 'create a control object to use as the enumerator
            For Each ctl In TabPage1.Controls 'enumerate the collection
                If ctl.GetType.ToString = chk.GetType.ToString Then 'determine if the current control is in fact a checkbox
                    CType(ctl, CheckBox).Checked = True 'if we're here, then the current control is a checkbox.  You must convert the object to a checkbox before setting the checked property
                End If
            Next
0
 
LVL 2

Accepted Solution

by:
djdidge earned 420 total points
ID: 11716168
try this... very similar to some of the others but perhaps a tad more readable

        Dim Ctrl As Control
        Dim childCtrl As Control

        For Each Ctrl In fMain.tabAll.TabPages(1).Controls()
            For Each childCtrl In Ctrl.Controls
                If TypeOf childCtrl Is CheckBox Then CType(childCtrl, CheckBox).Checked = False
            Next childCtrl
        Next Ctrl
0
 
LVL 1

Author Comment

by:Grunge
ID: 11716187
wow this topic suddenly took off!....

give me a tad to check the offerings then i will grade.

Regards

Grunge
0
 
LVL 1

Author Comment

by:Grunge
ID: 11716201
Thx all for your comments...
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question