Windows Develop Bookmark and Share   
 index > Windows Forms General > problem in closing a form ????????
 

problem in closing a form ????????

Hi

i have a login form and MDIForm.

After authentication i am creating object of MDI and passing login form object

Mdiform1 frm = new Mdiform1(this);

frm.show();

then in MDIform's constructor i am writing

public MDIForm1(frmLogin frm)

{

frm.close();

frm.dispose();

InitializeComponent();

}

The application exits automatically.

What's wrong???????

Sanjay Sutar  Tuesday, October 30, 2007 6:47 AM

Hi, San,

Based on my understanding, when you MDI window is about to show, the application just quits, isn't it?

I thinik the frmLogin is your main Window.

If you open Program.cs, you will find this line

Code Block

.Run(new frmLogin());

Code Block

static void Main()

{

Application.EnableVisualStyles();

Application.SetCompatibleTextRenderingDefault(false);

frmLogin form1 = new frmLogin();

if (form1.ShowDialog() == DialogResult.OK)

{

form1.Dispose();

Application.Run(new MDIForm1());

}

else

{

MessageBox.Show("Sorry, you are not authorized!!");

}

}

http://msdn2.microsoft.com/en-us/library/system.windows.forms.application.run.aspx

Hope this helps,

Regards

Yu Guo â€?MSFT  Thursday, November 01, 2007 5:47 AM

Hi, San,

Based on my understanding, when you MDI window is about to show, the application just quits, isn't it?

I thinik the frmLogin is your main Window.

If you open Program.cs, you will find this line

Code Block

.Run(new frmLogin());

Code Block

static void Main()

{

Application.EnableVisualStyles();

Application.SetCompatibleTextRenderingDefault(false);

frmLogin form1 = new frmLogin();

if (form1.ShowDialog() == DialogResult.OK)

{

form1.Dispose();

Application.Run(new MDIForm1());

}

else

{

MessageBox.Show("Sorry, you are not authorized!!");

}

}

http://msdn2.microsoft.com/en-us/library/system.windows.forms.application.run.aspx

Hope this helps,

Regards

Yu Guo â€?MSFT  Thursday, November 01, 2007 5:47 AM

You can use google to search for other answers

Custom Search

More Threads

• Scrolling a SplitContainer (newbie alert)
• DataGridView Row Copying problem.
• button function
• What is an imagenode?
• InvokeRequired but still "Illegal cross-thread operation"
• ErrorProvider Blink Rate
• Redrawing buttons...using inheritance
• How do I Maximize my form on startup? C#
• Displaying many details inside a text box
• RadioBox CheckedChanged Event not firing