473,406 Members | 2,273 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,406 software developers and data experts.

Finding name and type

Finding name and type

In the activate procedure of a form I want to write to the debug window,
name and type of all controls at that actual form. Is there a smart way to
do that?

Allso for the entire application I want to print the name of all forms to
the debug window.

TIRislaa
Nov 21 '05 #1
3 1080

This should help you for the controls,but it isn' t a complete answer
because if you've got a panel or a groupbox you'll have to check if a
control is a panel or groupbox and then also print all controls contained in
the panel or groupbox. But this should get you started

Dim ctr As Control
For Each ctr In Me.Controls
Debug.WriteLine(ctr.Name)
Next

hth Peter

"Tor Inge Rislaa" <no*************@rislaa.no> wrote in message
news:_P****************@news4.e.nsc.no...
Finding name and type

In the activate procedure of a form I want to write to the debug window,
name and type of all controls at that actual form. Is there a smart way to
do that?

Allso for the entire application I want to print the name of all forms to
the debug window.

TIRislaa

Nov 21 '05 #2
Hi Tor,

To do so, you can write the following code,

Dim c As Control
For Each c In Me.Controls
Diagnostics.Debug.WriteLine(c.GetType().ToString)
Next

For more information on how to use Controls Collection, you can refer to the
following link

[Controls Collection Changes in Visual Basic .NET]
http://msdn.microsoft.com/library/de...albasicnet.asp

HTH

Mona
"Tor Inge Rislaa" <no*************@rislaa.no> wrote in message
news:_P****************@news4.e.nsc.no...
Finding name and type

In the activate procedure of a form I want to write to the debug window,
name and type of all controls at that actual form. Is there a smart way to
do that?

Allso for the entire application I want to print the name of all forms to
the debug window.

TIRislaa


Nov 21 '05 #3
Recursion solves the problem with printing controls that contain other
controls (such as Form, Panel or GroupBox). Because all controls--including
Forms--derive from Control, which has a Controls collection, it's simple.

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
showControlTypeName(Me, 0)
End Sub

Private Sub showControlTypeName(ByVal ctl As Control, ByVal indent As
Integer)
Debug.WriteLine(Space(indent * 3) & ctl.Name & ", " &
ctl.GetType().Name)
For Each child As Control In ctl.Controls
showControlTypeName(child, indent + 1)
Next
End Sub

"Tor Inge Rislaa" <no*************@rislaa.no> wrote in message
news:_P****************@news4.e.nsc.no...
Finding name and type

In the activate procedure of a form I want to write to the debug window,
name and type of all controls at that actual form. Is there a smart way to
do that?

Allso for the entire application I want to print the name of all forms to
the debug window.

TIRislaa

Nov 21 '05 #4

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

Similar topics

17
by: Sean Ross | last post by:
Hi. Recently I made a small script to do some file transferring (among other things). I wanted to monitor the progress of the file transfer, so I needed to know the size of the files I was...
4
by: Kevin Dean | last post by:
I'm trying to create an XSL transformation that will strip out development-specific attributes from deployment descriptors and other XML files. I have already successfully done so with web.xml but...
0
by: Victor Hadianto | last post by:
Hi, Say for example I have this simple XSD: <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://tempuri.org/po.xsd" xmlns="http://tempuri.org/po.xsd"...
0
by: Victor Hadianto | last post by:
Hi, Say for example I have this simple XSD: <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://tempuri.org/po.xsd" xmlns="http://tempuri.org/po.xsd"...
2
by: Greg Allen | last post by:
Is there an easy way to find an element by name given a XmlSchema object? Or do I have to parse the entire schema myself to search for it? Do I somehow need to use XmlSchemaXPath? If so, how? ...
1
by: hazz | last post by:
"Value cannot be null.\r\nParameter name: type" is the exception thrown after the CreateInstance method below. Type t = Type.GetType(GetConfigValue("PasswordProvider")); IPasswordProvider ppdr=...
6
by: Tor Inge Rislaa | last post by:
Finding name of all forms I want to create a procedure that can loop trough all objects of type form in an application and print the name property to the debug window. TIRislaa
2
by: lcaamano | last post by:
We have a tracing decorator that automatically logs enter/exits to/from functions and methods and it also figures out by itself the function call arguments values and the class or module the...
275
by: Astley Le Jasper | last post by:
Sorry for the numpty question ... How do you find the reference name of an object? So if i have this bob = modulename.objectname() how do i find that the name is 'bob'
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...
0
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...
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
jinu1996
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...
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...
0
tracyyun
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...
0
isladogs
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...

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.