473,382 Members | 1,365 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Accessing all controls on a tabcontrol??

I am using a tabcontrol alled for example:-

TabPage

There are several tabs on this tabcontrol with command buttons on them. I
want to loop through them but the following code does not work:-

For Each ctl in TabPage.Controls ... Next

However if I just loop through controls on one of the tabs - e.g. a tab
called tabFirst this works fine:-

For Each ctl in tabFirst.Controls ... Next

How do I get the Controls on all of the tabs??
Thanks

Paul Bromley
Nov 21 '05 #1
2 8299
Paul,

"Paul Bromley" <fl*******@dsl.pipex.com> schrieb:
There are several tabs on this tabcontrol with command buttons on them. I
want to loop through them but the following code does not work:-

For Each ctl in TabPage.Controls ... Next

However if I just loop through controls on one of the tabs - e.g. a tab
called tabFirst this works fine:-

For Each ctl in tabFirst.Controls ... Next

How do I get the Controls on all of the tabs??


\\\
For Each tab As TabPage In Me.TabControl1.TabPages
For Each ctr As Control In tab.Controls
...
Next ctr
Next tab
///

Note that this won't find controls which are nested in container controls
placed on the tab pages.

BTW: I would not use the name 'TabPage' for a tab control because the tab
pages are instances of the class 'TabPage', which could be misleading for
the reader.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #2
Thanks Herfried,
I suspected that I needed to loop through through the tabpages. I had
foolishly placed:-

For Each ctr As Control In Controls

In my code instead of:-

For Each ctr As Control In tab.Controls
Thanks once again.
Paul Bromley

T

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Paul,

"Paul Bromley" <fl*******@dsl.pipex.com> schrieb:
There are several tabs on this tabcontrol with command buttons on them. I want to loop through them but the following code does not work:-

For Each ctl in TabPage.Controls ... Next

However if I just loop through controls on one of the tabs - e.g. a tab
called tabFirst this works fine:-

For Each ctl in tabFirst.Controls ... Next

How do I get the Controls on all of the tabs??


\\\
For Each tab As TabPage In Me.TabControl1.TabPages
For Each ctr As Control In tab.Controls
...
Next ctr
Next tab
///

Note that this won't find controls which are nested in container controls
placed on the tab pages.

BTW: I would not use the name 'TabPage' for a tab control because the tab
pages are instances of the class 'TabPage', which could be misleading for
the reader.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Duncan | last post by:
It seems that controls that are in a form's ComponentTray (e.g. ToolTip, ErrorProvider) don't appear on its list of controls (FormName.Controls). Is there any way I can get hold of them?
1
by: Paul Maidment | last post by:
Hi, I am a bit green when it comes to .net development so please excuse me if this question is obvious or has been asked before... I am trying to programmatically access a label control...
6
by: arvee | last post by:
Is there a way to access controls (and their properties) in a user control? The Web Form Designer marks controls as 'Protected' which makes them inaccessable from the host form. If I mark them as...
2
by: Robert Kemp | last post by:
I am creating a non-visible/tray control that monitors other custom controls for changes (among other things). One of the monitored controls is a new textbox that adds functionality to the...
0
by: Geoff Sullivan | last post by:
Are controls inside a nested master accessible? I have a master (b) which references another master (A). In master (b) I has several ASP controls. On the Page_Load of master (b), I can't seem to...
1
by: Dave | last post by:
I have the following ASP.NET 2.0 code (simplified here for ease): <asp:Repeater id="SearchResultsRepeater" runat="server"> <ItemTemplate> <uc:SearchResult ID="SearchResult"...
0
by: khalid sohail | last post by:
hi can any1 help me in accessing controls that exist in datagrid using the javascript.......ordinary that controls are access by the document.getelementById('controlid') mathod but that does not...
0
by: khalid sohail | last post by:
hi can any1 help me in accessing controls that exist in datagrid using the javascript.......ordinary that controls are access by the document.getelementById('controlid') mathod but that does not...
1
by: maarif | last post by:
The controls placed over an ASP.NET page can be accessed using following loop: For Each lControl In Page.Controls . . . . . . . . Next BUT this works only in code behind of that particular...
2
by: San24 | last post by:
Guys, Let me explain the application I have - Form > Main Tab Control > Main Tab Page > User Control > Sub Tab Control > Sub Tab Page > User Control > Contols/Text Box. Form - The main...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.