|
-
Apr 26th, 2007, 07:40 PM
#1
Thread Starter
Hyperactive Member
load 2 forms
hello!
i want to load the frmMain then the frmLogin (showdialog)
how could i do that?
tnx
-
Apr 26th, 2007, 08:05 PM
#2
Re: load 2 forms
Handle the Shown event of your main form, create an instance of your login form and call its ShowDialog method.
-
Apr 26th, 2007, 10:22 PM
#3
Thread Starter
Hyperactive Member
-
Apr 26th, 2007, 10:38 PM
#4
Re: load 2 forms
 Originally Posted by basti42
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?
Last edited by jmcilhinney; Apr 26th, 2007 at 10:47 PM.
-
Apr 26th, 2007, 10:45 PM
#5
Thread Starter
Hyperactive Member
Re: load 2 forms
ok sorry...
im am new to c# and obviously im not smart as you are
-
Apr 26th, 2007, 10:51 PM
#6
Re: load 2 forms
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.
-
Apr 27th, 2007, 12:29 AM
#7
Thread Starter
Hyperactive Member
Re: load 2 forms
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();
}
-
Apr 27th, 2007, 09:27 AM
#8
Re: load 2 forms
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|