[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

For Each control in TabPage

Posted on 2004-08-04
10
Medium Priority
?
329 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
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…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

650 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