Which Event is occurred before Form Load event??
Because I have a timer control for which I have written timer.start() method in form load event and current time is displayed in Label Control. Timer starts when the form Loads but it takes few seconds to show the time, so is there any other way to show the time fast.
Thanks in Advance !!!
Form.Load occurs when a form has been completely constructed, all controls have been initialised, and the form is ready to be shown. That only happens when you try to make a form visible (i.e. call Show or ShowDialog on it) for the first time.
You can start things in the form's constructor. However, calling anything which relies on controls being completely initialised before the Load event is received is a bad idea, because they might not be (i.e. they might not yet have window handles yet, data binding won't have happened, etc).
In this case you should set the text of the label in the constructor or in the Load event handler. Timers only start raising events when the interval has elapsed, so you should set the label to a sensible initial value as well as starting the timer.
In addition to the Solution 1 by BobJanova:—SA
This way, this event is a "fake" one. I mean, yes, this is a real event, but if it was not exist, the user's power would not be changed a bit. Unlike other events which are invoked by the code the user cannot get into. It also important to understand that an event cannot be invoked from anywhere except the class where the event instance was declared, not even in a derived class, so the user would not have any hook to the event except adding a handler to the invocation list of the event instance.
This is not the case for the event
Form.Load. Basically, everything the user wants to add to the handle of this event, can simply be called from withing a form's constructor at the very end. This is exactly what I personally do; never handle this event, because I think this is unnatural and excessive.
So, why this event was introduced? I don't really know, can only speculate. It makes ASP.NET,
System.Windows.Forms and WPF libraries a bit more similar, so it would exploit the user's habit's of using
Page.Load. Also, it mimics the Designer-based "development", where an event handler is added by the Designer. I see only one possible motivation for that in Microsoft: pleasing the weak minded was always on of the priorities in this company. It makes an illusion of "easy" development, and it is really easier… when it comes to the demo applications and simplest ad-hoc project. In real development, Designer means too much of manual repetitive work with poorly maintainable code. What you do, depends on your choice, your concrete case and individual taste.
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)