473,388 Members | 1,425 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,388 software developers and data experts.

How to get all the controls on form and non-form?

Me.Controls can get all the controls on the form, but i want to get all the
controls include non-from controls, for example ToolTip, ContextMenuStrip...
Thank you
Nov 10 '08 #1
4 4500
On Nov 10, 6:16*am, YXQ <Y...@discussions.microsoft.comwrote:
*Me.Controls can get all the controls on the form, but i want to get all the
controls include non-from controls, for example ToolTip, ContextMenuStrip....
Thank you
I think because they don't inherit Control class, as a result they're
not identified as controls.
See which classes/interfaces they implement. For example ToolTip class
inherits Component class, not control:
http://msdn.microsoft.com/en-us/libr...s.tooltip.aspx

So, you can loop Components to get them as follows:

For Each comp As System.ComponentModel.Component _
In Me.components.Components
' Tooltip and ContextMenuStrip will be found here
Next

Hope this helps,

Onur Güzel
Nov 10 '08 #2
yxq
You are a expert, thank you, but if this code is in moulde sub, for example:

Public sub AAA(Byval FormName as Form)
For Each comp As System.ComponentModel.Component In
FormName.components.Components
' Tooltip and ContextMenuStrip will be found here
Next
End Sub

The code above will not work if replace "Me" with "FormName", why?
Thank you
"kimiraikkonen" <ki*************@gmail.com>
??????:f2**********************************@g17g20 00prg.googlegroups.com...
On Nov 10, 6:16 am, YXQ <Y...@discussions.microsoft.comwrote:
Me.Controls can get all the controls on the form, but i want to get all
the
controls include non-from controls, for example ToolTip,
ContextMenuStrip...
Thank you
I think because they don't inherit Control class, as a result they're
not identified as controls.
See which classes/interfaces they implement. For example ToolTip class
inherits Component class, not control:
http://msdn.microsoft.com/en-us/libr...s.tooltip.aspx

So, you can loop Components to get them as follows:

For Each comp As System.ComponentModel.Component _
In Me.components.Components
' Tooltip and ContextMenuStrip will be found here
Next

Hope this helps,

Onur Güzel
Nov 10 '08 #3
Because the 'components' field in a form is Private, therefore it is
visible only from within the form.

On Tue, 11 Nov 2008 06:21:10 +0800, "yxq" <ga***@163.netwrote:
>You are a expert, thank you, but if this code is in moulde sub, for example:

Public sub AAA(Byval FormName as Form)
For Each comp As System.ComponentModel.Component In
FormName.components.Components
' Tooltip and ContextMenuStrip will be found here
Next
End Sub

The code above will not work if replace "Me" with "FormName", why?
Thank you
"kimiraikkonen" <ki*************@gmail.com>
??????:f2**********************************@g17g2 000prg.googlegroups.com...
On Nov 10, 6:16 am, YXQ <Y...@discussions.microsoft.comwrote:
>Me.Controls can get all the controls on the form, but i want to get all
the
controls include non-from controls, for example ToolTip,
ContextMenuStrip...
Thank you

I think because they don't inherit Control class, as a result they're
not identified as controls.
See which classes/interfaces they implement. For example ToolTip class
inherits Component class, not control:
http://msdn.microsoft.com/en-us/libr...s.tooltip.aspx

So, you can loop Components to get them as follows:

For Each comp As System.ComponentModel.Component _
In Me.components.Components
' Tooltip and ContextMenuStrip will be found here
Next

Hope this helps,

Onur Güzel
Nov 10 '08 #4
On Nov 11, 12:21*am, "yxq" <ga...@163.netwrote:
You are a expert, thank you, but if this code is in moulde sub, for example:

Public sub AAA(Byval FormName as Form)
* * For Each comp As System.ComponentModel.Component In
FormName.components.Components
* * * * ' Tooltip and ContextMenuStrip will be found here
* *Next
End Sub

The code above will not work if replace "Me" with "FormName", why?
Thank you

"kimiraikkonen" <kimiraikkone...@gmail.com>
??????:f2c9053a-4fc0-4ac3-b23e-f09df16cd...@g17g2000prg.googlegroups.com....
On Nov 10, 6:16 am, YXQ <Y...@discussions.microsoft.comwrote:
Me.Controls can get all the controls on the form, but i want to get all
the
controls include non-from controls, for example ToolTip,
ContextMenuStrip...
Thank you

I think because they don't inherit Control class, as a result they're
not identified as controls.
See which classes/interfaces they implement. For example ToolTip class
inherits Component class, not control:http://msdn.microsoft.com/en-us/libr....forms.tooltip....

So, you can loop Components to get them as follows:

For Each comp As System.ComponentModel.Component _
In Me.components.Components
' Tooltip and ContextMenuStrip will be found here
Next

Hope this helps,

Onur Güzel
Thanks for the feedback,

For the problem, as Jack said, "components" variable supplied with
Private access modifier within that form. To call through other form,
you need to call the loop from other form using "Me".

HTH,

Onur Güzel
Nov 11 '08 #5

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

Similar topics

1
by: Paul Hodgson | last post by:
Is there any easy way to have .ascx controls used by pages in different virtual directories? My situation is that I have some pages that need to be accessed using SSL - so I've put these pages...
3
by: Nhat Yen | last post by:
Hi everyone, I don't know why all the controls of the Table class (server control) has to be reconstructed for each page load. The MSDN said that it is because the children controls are not the...
1
by: Robert Howells | last post by:
Perhaps I'm just too new at this to pull it off, or perhaps it's just bad architecture. I'd appreciate some feedback on the the wisdom (or lack thereof) in attempting the following: I'm not new...
3
by: rbutch | last post by:
guys im building an application, that franky is pretty huge when it comes to controls. about 320 total dropdown list boxes will be populating the same amt of textboxes. and going to the server...
0
by: bminder | last post by:
Hello, Why would a web user control and master page not have access to a shared method in a library, when all regular pages do? For example, i have a library which has public class AAA. Public...
66
by: Cor | last post by:
Hi, I start a new thread about a discussion from yesterday (or for some of us this morning). It was a not so nice discussion about dynamically removing controls from a panel or what ever. It...
8
by: Klaus Jensen | last post by:
Hi! I would like to build a small application, that should be embedded in a webpage. I want to develop it using VB.Net of course, and have the usual opportunities of a windows app... A common...
4
by: Marcos Beccar Varela | last post by:
Hello! I´m a newbbie in VB.NET and I´m having a problem. I have many forms and I need to create a label (for example) in each of them. Is there a way to make a function which I can call it from any...
1
by: Wayne | last post by:
Not sure if anyone else has noticed this, but it gets around one of the more annoying limitations of using themed controls. Normally when using themed controls a triple state check box looks the...
6
by: =?Utf-8?B?TWFyaw==?= | last post by:
Hi... Tried posting this on Build Controls but then saw that's a pretty slow group... Kind of a typical request from product management - they want to be able to swap in different 3rd party...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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...
0
marktang
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,...
0
Oralloy
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.