Get Information about Forms

  • Thread starter Thread starter Mike
  • Start date Start date
M

Mike

Hi,

Can I NOT from Form class get information about form's properties,
control located on the form , etc? I would like to do it from any
module at my project .

Thanks
 
Mike said:
Hi,

Can I NOT from Form class get information about form's properties,
control located on the form , etc? I would like to do it from any
module at my project .

Thanks


Mike,

If you have an instance of your form referenced in a variable, you can
access all of its public members. If you want to expose private or protected
members, you'll need to wrap them with custom public members.
If you don't have a reference, you can access only Public Shared members and
Public constructors.

- Pete
 
AirPete said:
Mike,

If you have an instance of your form referenced in a variable, you can
access all of its public members. If you want to expose private or protected
members, you'll need to wrap them with custom public members.
If you don't have a reference, you can access only Public Shared members and
Public constructors.

- Pete

Pete,
Thanks for your answer . I already use reference and do exactly what
you said

I not good formulated my question: does .Net contain collection that
has information about all forms and modules at my project
(application).
And when I get element from that collection I can get access to public
properties and method of the any particular form.

Thanks
 
[snip]
Mike said:
Pete,
Thanks for your answer . I already use reference and do exactly what
you said

I not good formulated my question: does .Net contain collection that
has information about all forms and modules at my project
(application).
And when I get element from that collection I can get access to public
properties and method of the any particular form.

Thanks

Check out the System.Reflection namespace, especially the Assembly class and
its static/shared GetExecutingAssembly method. Then you can use its GetTypes
method to get that info.

Example (pseudocode, not tested):

Dim this as Assembly = Assembly.GetExecutingAssembly()
Dim types() as Type = this.GetTypes()
Dim typec as Type
For each typec In types
Console.WriteLine(type.Name)
Next

This should print a list of all types in your project.

- Pete
 
Back
Top