List Info

Thread: C-Sharp (C#) Group: is it possible to define the order in which winform user controls load?




C-Sharp (C#) Group: is it possible to define the order in which winform user controls load?
user name
2006-03-31 09:50:00
I have one control that absolutely must load before any
other controls,
due to some initialisation code within it. Is there a way of
getting
this control to load first? Moving the code from the load
event to the
constructor isn't an option to get around this issue.

Any suggestions would be very gratefully received!!!

Greg.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "C-Sharp (C#)" group.
To post to this group, send email to C_Sharpgooglegroups.com
To unsubscribe from this group, send email to
C_Sharp-unsubscribegooglegroups.com
For more options, visit this group at http://groups.
google.com/group/C_Sharp
-~----------~----~----~----~------~----~------~--~---

C-Sharp (C#) Group: Re: is it possible to define the order in which winform user controls load?
user name
2006-03-31 11:03:12
Use events to indicate a Load of the first control and tie the other controls in to this event instead of their own Load event.

On 3/31/06, Greg <yahoo.co.uk"> gregwilliams001yahoo.co.uk> wrote:

I have one control that absolutely must load before any other controls,
due to some initialisation code within it. Is there a way of getting
this control to load first? Moving the code from the load event to the
constructor isn't an option to get around this issue.

Any suggestions would be very gratefully received!!!

Greg.



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "C-Sharp (C#)" group.
To post to this group, send email to C_Sharpgooglegroups.com
To unsubscribe from this group, send email to C_Sharp-unsubscribegooglegroups.com
For more options, visit this group at http://groups.google.com/group/C_Sharp
-~----------~----~----~----~------~----~------~--~---

C-Sharp (C#) Group: Re: is it possible to define the order in which winform user controls load?
user name
2006-03-31 11:21:08
Thanks Liam, that's a good idea.

However, this won't work for my scenario becuase at program
start up
the controls are completely independant and dont know about
any of the
other controls. Therefore, they can't register to listen
for events.
The intialisation process for each control involves talking
to the main
form and asking for references to the other controls, in
order to
register for feedback. 

Greg.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "C-Sharp (C#)" group.
To post to this group, send email to C_Sharpgooglegroups.com
To unsubscribe from this group, send email to
C_Sharp-unsubscribegooglegroups.com
For more options, visit this group at http://groups.
google.com/group/C_Sharp
-~----------~----~----~----~------~----~------~--~---

C-Sharp (C#) Group: Re: is it possible to define the order in which winform user controls load?
user name
2006-03-31 12:10:35
Ahhh I see why this poses you a problem now!

There are three ways round this situation off the top of my head:

1. Manually call the first Controls Load method from within your form from within an override of the base OnLoad method (the other controls will not have their Load event fired until base.OnLoad(e) has been called so just stick the call in before that call). Obviously with this one you will have to stick a huge if statement around your first controls Load method so it only fires once rather then every time.

2. Attach all dependant controls to the first controls Load method (so the methods to handle the event are in the dependant controls but the event which fires them is a member of the primary one).

3. Define a class that contains an event in class scope (so defined as static) and also the delegate for that event. Dependant controls hook in to this event via their constructors and primary control calls this event when it is finished with the Load.

#3 would be the best of the three as it poses the lease risk of things breaking with future artichectual changes and means the Form doesn't have to hook the controls together. Shout if you need a bit of sample code to illustrate any of these.

Liam

On 3/31/06, Greg <yahoo.co.uk">gregwilliams001yahoo.co.uk> wrote:

Thanks Liam, that's a good idea.

However, this won't work for my scenario becuase at program start up
the controls are completely independant and dont know about any of the
other controls. Therefore, they can't register to listen for events.
The intialisation process for each control involves talking to the main
form and asking for references to the other controls, in order to
register for feedback.

Greg.



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "C-Sharp (C#)" group.
To post to this group, send email to C_Sharpgooglegroups.com
To unsubscribe from this group, send email to C_Sharp-unsubscribegooglegroups.com
For more options, visit this group at http://groups.google.com/group/C_Sharp
-~----------~----~----~----~------~----~------~--~---

[1-4]

about | contact  Other archives ( Real Estate discussion Medical topics )