Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

When I initialize a new form to open, the subroutine in the new form starts before the new form is shown on the screen and so when the subroutine finishes and the MsgBox comes up, the form isn't showing.

Is there a way to make the form pop up first before the subroutine starts?

Thanks a lot for any help
Posted

1 solution

I reckon you are calling it in the Load event. You need to call it in the Shown event (fired only once).

C#
private void Form1_Shown(object sender, EventArgs e)
{
    MessageBox.Show("***");
}
 
Share this answer
 
Comments
RoomTen 2-Nov-11 12:06pm    
Well I am calling the subroutine in the Load event, and I just tried calling it in the Shown event as you have said but it still doesn't work. Instead the Form comes up but the subroutine never starts.
Nish Nishant 2-Nov-11 12:07pm    
Put a breakpoint and trace through the code.
RoomTen 2-Nov-11 12:12pm    
Well actually I managed to get it sorted now using your code. Thanks alot :)
Nish Nishant 2-Nov-11 16:25pm    
You're welcome.
LanFanNinja 10-Nov-11 10:33am    
+5 for using the word reckon(I'm from the south). :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900