hello!
i want to load the frmMain then the frmLogin (showdialog)
how could i do that?
tnx
Printable View
hello!
i want to load the frmMain then the frmLogin (showdialog)
how could i do that?
tnx
Handle the Shown event of your main form, create an instance of your login form and call its ShowDialog method.
not working
Gee, could you give any less information? What I suggested will do what you asked for. If it's not working then you're not doing it properly. If you don't show us or explain to us what you are doing then we can't help. Is that not common sense?Quote:
Originally Posted by basti42
ok sorry...
im am new to c# and obviously im not smart as you are
Like I said, it's common sense and nothing to do with C#. If you want a problem diagnosed you have to provide information, whatever it relates to. Would you expect a doctor to give you the right medicine if you went into their office and said "I'm sick"? Explain your situation. Show us the code you're using. Tell us what "not working" means? Is an exception thrown? Does your computer explode? Something else? We can't guess. You have to tell us. When you do then we can hopefully provide a solution.
yeah your right it's a common sense but you must consider
that's why im seeking for your help because i already searched through
the net and im failed. for you it's simple because you know it's hard for
me because i don't know simple as that.
private void frmMain_Load(object sender, EventArgs e)
{
frmLogin fLogin = new frmLogin();
fLogin.ShowDialog();
}
That code will do what you asked for. I assume that your problem now is that the same thing happens whether the login is successful or not. If that's the case then that's what you should have said. Like I said, "doesn't work" doesn't really tell us much.
When you display a form by calling its ShowDialog method you normally set its DialogResult property to dismiss it. The DialogResult property value indicates the result of the dialogue, e.g. OK, Cancel, etc. In your case you would set it to OK for a successful login and Cancel otherwise.
That DialogResult value then gets returned by the ShowDialog method. That's how the caller is able to determine what happened and how to proceed. If ShowDialog returns OK you know the login was successful and you proceed accordingly.
Note also that I said originally said handle the Shown event, not the Load event. Load is raised before the form is displayed, while Shown is raised after. You can handle either but your original question implied after. Note also that once the Load event is raised you can't stop the form being shown, so even if you try to close it it will flash on screen for a moment.