Firstly, see how much more readable your question is using the correct formatting? always use the [code block] around code (<pre></pre>).
Secondly, avoid the name
main
for any object! The
Main
method has a special significance in any C# program (and C/C++), using it as a name will end in disaster at some point. I would suggest
FormMain
or something similar.
It seems that your problem is in the middle code block where you are creating a whole new
main
and calling
ShowMenu();
on that. What you really want is to call
ShowMenu
on the existing
main
instance.
The easiest way to rectify this in your situation is to show the login form using
ShowDialog
and forget about the
MdiChild
thing for it. You can then set the
DialogResult
of the login form and test that in the main form.
if(ls.ShowDialog(this) == DialogResult.Ok)
{
ShowMenu();
}
ls.Dispose();