Reputation: 586
Is there any event or any other notification we can get, before a windows form is loaded?
I want to process some code, before the form is loaded.
Upvotes: 0
Views: 1633
Reputation: 953
Like the others said you could definitely use the Form Load event to run the code before the form is loaded and another way would be to run the code in the Main
function in Program.cs
which is where the control to your application starts. And this is if your code has nothing to do with the UI of the initial form.
Upvotes: 0
Reputation: 808
I'm not sure what you mean by "while the form is showing". I suppose it means "Just before the form starts rendering".
And for that, I would recommend:
And for further reference:
Upvotes: 4
Reputation: 26632
The Load
event is fired just in time when form is showing. However, the form is not yet visible.
But don't forget, any computation in UI thread will prevent any UI code to be processed. In result "process some code while the form is showing" will be "stop the showing until some code is processed".
Upvotes: 2