Click here to Skip to main content
15,116,654 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
HI everybody


I have multiple forms, I need to close the current form -without clicking any button- and directly, automatically another form is opened in this project..
i am using show and close methods but either the 2 forms are appearing together or the current form is not appearing at all .

please somebody help me it is very urgent (No, it's not.)
thanks
Posted
Updated 25-Jun-11 6:56am
v3
Comments
Philippe Mori 25-Jun-11 15:52pm
   
Typically in a WinForms application the main windows should be visible for the life of the application. If that main windows (form) display other forms, then it is easy to show appropriate form.

If you don't want the main windows to be visible, then you can make it borderless, transparent, empty and/or hidden.
nourbt 25-Jun-11 15:55pm
   
no i am not talking about the main form..it's the other forms that should close and other forms to be displayed

1 solution

Instead of using separate forms, create a pair of child controls that have all of the appropriate controls on it, and depending on requirements, show/hide each child control when necessary.

EDIT =============

Simply add the appropriate database updating code to the Show or Hide event handlers. When the form is hidden, have it update the database. When it's show, have it retrieve info from the database (or whatever processing needs to happen to properly initialize the control.

Just in case you didn't know, a form is nothing more than a control itself. A UserControl is like a borderless form (it can contain other form controls, like text boxes, buttons, etc, or even additional UserControls. It is therefore easy to deduce that you can place the UserControl onto a form.
   
v3
Comments
nourbt 25-Jun-11 6:11am
   
John Simmons

ok i will try this but if you can give me more details, don't hesistate i am really in a hurry

thanks again
nourbt 25-Jun-11 6:13am
   
note that the child form will close again so that other form will open, i have about 7 forms that should open successively
nourbt 25-Jun-11 6:35am
   
let's make things clearer..each form is done to insert data in 7 tables of same database, so these forms are of different code
Philippe Mori 25-Jun-11 15:47pm
   
You might also create a "wizard" form that display the appropriate child form for the current step (or user control) in a panel. Then add some logic to move to the next step.

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