[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How We can find all the Component in a Form

Posted on 2005-05-11
10
Medium Priority
?
354 Views
Last Modified: 2010-04-16
How We can find all the Component in a Form
such as SqlConnection,MainMenu,Process ,etc...
tanks
0
Comment
Question by:shayan_rezvani
  • 5
  • 5
10 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 13977894
     foreach (Control current in this.Controls)
      {

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

      }

Bob
0
 

Author Comment

by:shayan_rezvani
ID: 13978768
this method can not find the component such as sqlConnection or MainMenu
helpme please
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 375 total points
ID: 13978914
Where are you trying to access this from?  Form?  Designer?

There is the IContainer components, but the components are not added to this collection.  You might be able to make this collection actually contain references to all the components, but that is probably not advisable.

These references have to somewhere, right?

Reference:
What's that "Windows Form Designer generated code" anyway?
http://www.vbinfozine.com/a_disposable_comp.shtml

Bob
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:shayan_rezvani
ID: 13979071
I Want to do that in DesignTime in Designer
tanks
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 13979107
What kind of designer are you creating?

Bob
0
 

Author Comment

by:shayan_rezvani
ID: 13979153
Form Designer
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 13979174
Can you find a ContainedControls collection?  Does this collection contain the MainMenu control?

Bob
0
 

Author Comment

by:shayan_rezvani
ID: 13979196
no
no
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 13979258
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
0
 

Author Comment

by:shayan_rezvani
ID: 13979482
Dear Friend
I think there is a Malentendu :(
I want Just to Find the Component in DesignTime

0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses
Course of the Month19 days, 15 hours left to enroll

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question