Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / .NET SDK / August 2006

Tip: Looking for answers? Try searching our database.

Loaded method

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Francois PIETTE - 09 Aug 2006 14:11 GMT
Does a component derived from System.ComponentModel.Component has a method
(Let's name it Loaded()) which is called by the form on which the component
is dropped when all component dropped on the form have been instanciated an
initialized ? Something called just after InitializeComponent() or after the
form constructor has been called.

Here is what I want to do:
The user drop a few components on a form. One of those components will
change his runtime behaviour depending on what is dropped on the form. So I
want this component iterate thru all components dropped on the same (form)
container to find out for some known classes instances and do whatever it
needs to do with that instances. To iterate thru all components, a component
need to "know" when InitializeComponent() is done or when the container
contructor is done or almost done.

Signature

Francois PIETTE
http://www.overbyte.be

"Peter Huang" [MSFT] - 10 Aug 2006 06:13 GMT
Hi Francois,

From your description, I understand that you want to iterate througth all
the components on a Forms.
Based on my research, you may iterate throught the components variable.
private System.ComponentModel.IContainer components = null;

But now all the component will be added into the collection, only the
component which has a special constructor will be added into the collection.
 Public Sub New(ByVal Container As System.ComponentModel.IContainer)
   Me.New()
   Container.Add(Me)
 End Sub
What's that "Windows Form Designer generated code" anyway?
http://www.vbinfozine.com/a_disposable_comp.shtml

Also all the methods exposed by System.ComponentModel.Component is listed
in the MSDN, it did not have such Load method.
Component Members  
http://msdn2.microsoft.com/en-us/library/system.componentmodel.component_mem
bers.aspx

Best regards,

Peter Huang

Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Francois PIETTE - 10 Aug 2006 08:05 GMT
Thanks for your answer.

> From your description, I understand that you want to
> iterate througth all the components on a Forms.

The question was not how to iterate thru all components but WHEN do that
iteration. I need to do that iteration when all component have been loaded
and initialized. That is at least after InitializeComponent() has been
called or after the form constructor has been called.

I don't want to tell my component user that he must call a method at the end
of InitializeComponent or at the end of the form's constructor. I would like
the component to do it automatically at the right moment. I'm porting code
from Delphi.win32 to C#. Delphi form's constructor iterate thru all
component Loaded() method when it has finished loading all components (more
or less after the equivalent of InitializeComponent). This is very handy
because any component can override his Loaded() method to prepare itself to
work with other components dropped on the same form at yet be sure all other
components are up and running. Should this be important, the Delphi IDE let
you select the order in which the components are created, the equivalent of
changing the order of component creation and initialization in
InitializeComponent().

btw: I'm using C#.

Signature

Francois PIETTE
http://www.overbyte.be

> Hi Francois,
>
[quoted text clipped - 15 lines]
> in the MSDN, it did not have such Load method.
> Component Members

http://msdn2.microsoft.com/en-us/library/system.componentmodel.component_mem
> bers.aspx
>
[quoted text clipped - 8 lines]
> ==================================================
> This posting is provided "AS IS" with no warranties, and confers no rights.
"Peter Huang" [MSFT] - 11 Aug 2006 03:47 GMT
Hi Francois,

Sorry for misunderstood, from your description, it seems that you want the
UserControl which will have a load event, we can handle that event and the
code will be called automatically when the UserControl is loaded in runtime
after the ctor and InitializeComponent is called. But the component did not
have the load event per the MSDN I post in my last reply.

Anyway, if you do want to enable this in component class, you may want to
leverage the .NET winform designtime feature that will do some
customization when you add the component into the Winform project.
For detailed information you may post in the newsgroup below.
microsoft.public.dotnet.framework.windowsforms.designtime

If you still have any concern, please feel free to post here.
Thanks!

Best regards,

Peter Huang

Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.