Problem Displaying a form after another form

C

Cybertof

Hello,

I have a strange behavior.

On a MyForm form, i have a button with this code
----> MessageBox.Show("hello");
When i start the project with this single form
----> Application.Run(new MyForm());
It works : when i click then i have the messagebox and the form still
continues its message loop.


Now if before displaying MyForm, i display another one, when i click the
button, the MessageBox appears, but once clicking OK, the form is closed
! (and no call to this.Close() was done.....)


***************
Sample Code :
***************


//[STAThread]
static void Main(string[] cmdLine )
{
Application.Run(new MyFirstForm()); // (***)
Application.Run(new MyForm());
}

(***) with this line, any click on a button in MyForm to display a
MessageBox will close MyForm.
(if i use Console.WriteLine("test") instead of a MessageBox the form is
not closed....)


Help....


Cybertof.
 
C

Cybertof

Sorry ?

I just want a 'Login' form to identify the user, and once the
identification is ok, then only displays the real main form....

Cybertof.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top