Click to See Complete Forum and Search --> : ShowDialog Problem


draj
June 11th, 2003, 02:16 PM
In the main() function
I have written the following code.

void main()
{
Form2 testDialog = new Form2();

if (testDialog.ShowDialog() == DialogResult.OK)
{
// Read the contents of testDialog's TextBox.
result.Text = testDialog.TextBox1.Text;
}
else
{
result.Text = "Cancelled";
}
testDialog.Dispose();
Global.frmMain = New frmMain() ;
Global.frmMain.ShowDialog();

}

I get the form load event for the first form testDialog.
But I don't get the form load event for the form frmMain.
But if I use form.Show() instead of form.ShowDialog() Load event gets triggered but the Application shuts down since main() exits.
Anybody know how to resolve this issue?

Thanks,
Raj

BinaryAnge
June 11th, 2003, 09:33 PM
Is this code in frmMain? It seems like your coding somewhere between c++ and c#. You probably shouldnt put this code in the void main(). Insted let the app just display the first form on its own, then use the show dialog for the second form. The reason your app exits when you use the show method is its not modal and your main thread is terminating which ends the app. Its hard to tell exactly what your doing, but there isnt much coding done the the main() of a normal app anymore. If this doesnt help, post alittle more detail about what your trying to do and ill see if i can help

BinaryAnge
June 11th, 2003, 09:37 PM
basically what im saying is that the only thing that should be in your main() is application.run. Then in your first form load event do you form 2 showdialog stuff.