Hi,
Is there actually a way to get ALL the Controls on a Form? While using the
ControlCollecti on, it only returns the Controls that are directly on the
Form, not the controls that are on a (TableLayout)Pa nel etc.
I never found something like that, but it just would be nice in my opinion
:-)
Thanks,
Pieter 6 3039
Hi,
you can use following code snippet.
foreach (Control ctr in this.Controls)
{
if (ctr.HasChildre n) // Check for Containder Control
{
//Controls on other control (e.g Panel)
}
}
Hope this will solve your problem
Prasad.
"DraguVaso" wrote: Hi,
Is there actually a way to get ALL the Controls on a Form? While using the ControlCollecti on, it only returns the Controls that are directly on the Form, not the controls that are on a (TableLayout)Pa nel etc.
I never found something like that, but it just would be nice in my opinion :-)
Thanks,
Pieter
private ControlCollecti on res = new ControlCollecti on();
public void GetControls(Con trol parent)
{
if (! parent is Form)
{
res.Add(parent) ;
}
foreach(Control c in parent.Controls )
{
GetControls(c);
}
}
"DraguVaso" <pi**********@h otmail.com> wrote in message
news:ud******** ******@TK2MSFTN GP10.phx.gbl... Hi,
Is there actually a way to get ALL the Controls on a Form? While using the ControlCollecti on, it only returns the Controls that are directly on the Form, not the controls that are on a (TableLayout)Pa nel etc.
I never found something like that, but it just would be nice in my opinion :-)
Thanks,
Pieter
On 20/09/2005 DraguVaso wrote: Hi,
Is there actually a way to get ALL the Controls on a Form? While using the ControlCollecti on, it only returns the Controls that are directly on the Form, not the controls that are on a (TableLayout)Pa nel etc.
You could use a recursive procedure.
private sub GetControls(Con trol ctlParent, ref ArrayList al)
{
al.Add(ctlParen t);
foreach(Control ctlChild in ctlParent)
GetControls(ctl Child, ref al);
}
Not tested, my development PC is off at the moment but something like
that should do it. Call it by setting up a new ArrayList and starting
with the Windows Form. If it doesn't recognise the Form as a control
you would need to start with:
private sub GetAllControls( )
{
ArrayList al = new ArrayList();
foreach(Control ctl in frmMain)
GetControls(ctl , ref al);
}
--
Jeff Gaines
Pieter Is there actually a way to get ALL the Controls on a Form? While using the ControlCollecti on, it only returns the Controls that are directly on the Form, not the controls that are on a (TableLayout)Pa nel etc.
Roughly done
\\\
Showall(me)
Private Sub ShowAll(ByVal parentCtr As Control)
For Each ctr As Control In parentCtr.Contr ols
Console.Write(c tr.name)
ShowAll(ctr)
Next
End Sub
///
I hope this helps,
Cor
Thanks guys, I guess recursion will indeed be the only solution for this. I
think it's kind of weird there isn't a Collection that returns everything on
a form, but so be it, hehe :-)
Pieter
"Cor Ligthert [MVP]" <no************ @planet.nl> wrote in message
news:eA******** *****@TK2MSFTNG P10.phx.gbl... Pieter
Is there actually a way to get ALL the Controls on a Form? While using
the ControlCollecti on, it only returns the Controls that are directly on the Form, not the controls that are on a (TableLayout)Pa nel etc. Roughly done \\\ Showall(me) Private Sub ShowAll(ByVal parentCtr As Control) For Each ctr As Control In parentCtr.Contr ols Console.Write(c tr.name) ShowAll(ctr) Next End Sub /// I hope this helps,
Cor
"DraguVaso" <pi**********@h otmail.com> schrieb: Is there actually a way to get ALL the Controls on a Form? While using the ControlCollecti on, it only returns the Controls that are directly on the Form, not the controls that are on a (TableLayout)Pa nel etc.
\\\
Private Sub RecurseControls (ByVal ctr As Control)
Debug.WriteLine (ctr.Name)
If ctr.HasChildren Then
For Each c As Control In ctr.Controls
RecurseControls (c)
Next c
End If
End Sub
..
..
..
RecurseControls (Me)
///
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Robert |
last post by:
Hello.
I have been trying out the Lebans ToolTip Classes at
http://www.lebans.com/tooltip.htm, to display "balloon" style help tips in a
form. The classes I am using are located at
http://www.lebans.com/DownloadFiles/A2kTooltip.zip
So far the classes work perfectly, except that now I need to extend it to
support other controls besides the ones given in the example form. I have
gotten it to work with some controls, but not others. I...
|
by: Saintor |
last post by:
What I do now is I put a value in the tag property, and using the
form_current event, I run through all controls properties until the ones
with the required tag value are met. Sound OK in theory, but it is ...
slow.
I thought having a table with the name, type of controls and put my 'tag
value' there. At the opening of the form, I would retrieve a recordset from
the table, and perform a subroutine on the current event to lock/unlock...
|
by: TD |
last post by:
This is the code under a command button -
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.BackColor <> RGB(255, 255, 255) Then
ctl.BackColor = RGB(255, 255, 255)
End If
Next ctl
|
by: Roger |
last post by:
Hi
In a Windows forms application I have 2 forms A and B; Form B inherits from
form A. Form A is never displayed and its only purpose is to be inherited
from and therefore contains mostly public/protected methods that I have
created (as well a few controls that inheriting forms may use). In my method
on form A (public virtual void setcontrols()) I need a list of all controls
on the instantiated form (in this example form B). Form B has a...
|
by: Sacha Korell |
last post by:
I'm trying to load a drop-down list with all DropDownList control names from
another page.
How would I be able to find those DropDownList controls? The FindControl
method will only find a certain control by id, but I want to find all
controls of a certain type (DropDownList in this case).
Is there an easier way than to get a control count of the page, loop through
all controls on that page, examine their type and, if they're a...
| |
by: Mr Newbie |
last post by:
I was thinking about developing a workflow application yesterday and was
musing over the different approaches than one could take in restricting
specific actions on a ticket( Form ) at any said stage.
One approach I have used on other systems is to prevent the action buttons
appearing. For example, if one did not have the Role of Administrator, one
would be prevented from deleting a ticket not created by oneself.
However, it did occur...
|
by: Mike Bulava |
last post by:
I have created a base form that I plan to use throughout my application let
call the form form1. I have Built the project then add another form that
inherits from form1, I add a few panel controls each with a couple of
controls in them I then rebuilt my project and my new panels and all
controls they contained are gone... I've looked through the Auto generated
code but don't see anything that looks wrong Any body have any idea why
this...
|
by: Ryan |
last post by:
Ok.. I have a form with lots of stuff on it; a tool strip panel, menu strip,
data binding elements (dataset, binding source, table adapter), tab control
with 7 tab pages, each page contains a picture box, lots of text boxes (for
input).. you get the idea. All of a sudden everything on the form has
disappeared, it looks like a blank, newly created form. I can still get to
the properties of every item on the form using the drop-down box in...
|
by: rizwanahmed24 |
last post by:
Hello
i have made a custom control. i have placed a panel on it. I want this
panel to behave just like the normal panel. The problem i was having is
that the panel on my custom control doesnt accept other controls. The
control i drag drop on it becomes the child of my custom control's
parent form and not the child of my custom control. Then i added this
line
""
before my custom control class (i dont know what this line does). Now
|
by: Mike |
last post by:
Hi,
I have a form with some controls, and a different class that needs to
modify some control properties at run time.
Hoy can I reference the from so I have access to its controls and
therefore being able to modify its properties?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |