The startup of my application is the main form then it has login.showdialog for login. I already finish this but I want to have a form appear when the user successfully logged in.

I tried putting this in my log in

form form = new form();

yes, the form shows but the login is behind it.. I need to completely close or hide it.. I also tried hiding it, the message form shows but the main form is being put aside by other open applications.

huunnn. first create a instance of your login form.when application satrted first it will show the main form and login form will be visible so on form load event.

login lg =new login();
Private Void MDIFOrm_load()
lg=new login();
lg.MdiParentForm=this;\\means it will appear in MDI paren form;

on login form button write this code

private void button_click()
\\if user successfully login then
lg=new login();
form f=new form();
f.MDIparent=this;\\ or write your Main mdi form name.;


try this it will work.

at the first line of mail load hide or close the login form
according to me close the login form so it will realease memoryb of system

Ok you need to think about what your method calls do and your order of execution.

The ShowDialog method does just that. It shows the form you created as a dialog box. This means that the code from your parent form stops executing (unless you have multiple threads running which I won't go into)

So when you get to the line form.ShowDialog() execution in that method pauses at that point, until you close the new dialog box.

What you should do, is put the Hide method *above* the ShowDialog call and then a show method *after* it.

If you want the login form to close and a new form to be shown, why not create the new form from your main form. You are showing the login form modally (ShowDialog) so when you close login the code execution will resume in the main form. Use the login forms DialogResult to determine if user successfully logged in then show your new form:

frmLogin login = new frmLogin(); //create login form
DialogResult loggedIn = login.ShowDialog(); //show login form and store returned DialogResult
if(loggedIn = DialogResult.OK) //if the user logged in correctly then show new form
    frmNewForm newForm = new frmNewForm();
    //do something else if user failed login

Use this.DialogResult = DialogResult.OK in your login form to confrim this.DialogResult = DialogResult.Cancel if login fails.

commented: i'll give it a try +1