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 / New Users / March 2006

Tip: Looking for answers? Try searching our database.

is it possible to define the order in which winform user controls load?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Greg - 31 Mar 2006 10:51 GMT
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.
Patrice - 31 Mar 2006 11:05 GMT
The only option I see for now would be tweaking the designer code. My
personal preference would be still to move this portion of code elsewhere
(page_load ?).

Some more details about why this is needed may help someone to make better
suggestions.
Signature

Patrice

>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
[quoted text clipped - 4 lines]
>
> Greg.
Greg - 31 Mar 2006 11:29 GMT
Thanks Patrice.

I tried tweaking the designer code - the order in which the controls
are loaded is not reflected to the order that they are being
instantiated by my main form. So it would appear that the order in
which they are loaded is determined by something else.

I dont want to move the initialisation code into the constructor as
that is called at design time as well as design time. designmode always
returns false within the constructor and so can't be used to
differentiate between design time and run time - and I need to avoid
trying to create objects (part of my initialisation) at design time!

Thansk again.

Greg.
Patrice - 31 Mar 2006 12:21 GMT
If this order (controls would be "created" in a given order but not "loaded"
in the same order ? how do you have checked this ?) is not under you control
it looks like you are out of luck.

You may still want to give some more details as it looks really an unusual
requirement. My personal strategy would be rather to get rid of this
requirement rather than trying to satisfy it.

Also if it must do something special on other controls, it could be just
implemented in a form you could inherit from.

Signature

Patrice

> Thanks Patrice.
>
[quoted text clipped - 12 lines]
>
> Greg.
Michael Bray - 31 Mar 2006 17:16 GMT
"Greg" <gregwilliams001@yahoo.co.uk> wrote in news:1143798682.140524.23580
@z34g2000cwc.googlegroups.com:

> 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.

You don't have any control over this.

If you absolutely require yours to load first then it is a bad design.  

It sounds as if you are trying to perform some operations on the other
controls in the forms.  If this is the case, I would suggest hooking your
own controls 'ParentChanged' event.  When the event is fired, then you can
iterate thru the parent's control collection.  You could also at that time
hook the parent's ControlAdded and ControlRemoved events in order to catch
controls that are added after your control.  I haven't actually tried this
but I think it should work.

-mdb
sanjeev@securlinx.com - 01 Apr 2006 00:18 GMT
You could instantiate the controls dynamically after
IntializeComponent; This would give you control in what order the
controls are loaded.

Rate this thread:







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.