Link to home
Start Free TrialLog in
Avatar of shayan_rezvani
shayan_rezvani

asked on

How We can find all the Component in a Form

How We can find all the Component in a Form
such as SqlConnection,MainMenu,Process ,etc...
tanks
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

     foreach (Control current in this.Controls)
      {

        Console.WriteLine(current.GetType.ToString());

      }

Bob
Avatar of shayan_rezvani
shayan_rezvani

ASKER

this method can not find the component such as sqlConnection or MainMenu
helpme please
ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I Want to do that in DesignTime in Designer
tanks
What kind of designer are you creating?

Bob
Form Designer
Can you find a ContainedControls collection?  Does this collection contain the MainMenu control?

Bob
no
no
First of all, I don't back away too often from a challenge :)

Secondly, I have not implemented a Forms Designer.

Thirdly, I don't have any idea of how to do this, but it forces me to research.

WinForms implement the IContainer interface, with the Container property.  The IContainer has a Components collection.

Does this get us anywhere?

Bob
Dear Friend
I think there is a Malentendu :(
I want Just to Find the Component in DesignTime