hi
i hava login page form(Login),when i click on login button i want to move another form(Users) and i want to close Login form.
i wrote this code in button click
UsersForm obj = new userForm();
obj.show();
this.close();//Login page close
once i call this.close() method both forms are closed ..
plz give me solution....
Loading

Nilanka DharmadasaRank #1,875 · 794 reputationPosted Nov 19, 2009, 6:49 PM EST
Use this method.
private void button1_Click(object sender, EventArgs e)
{
System.Threading.Thread mythread = new System.Threading.Thread(new System.Threading.ThreadStart(OpenNewFrom));
mythread.Start();
this.Close();
}
public static void OpenNewFrom()
{
Application.Run(new UsersForm());//Create an instance of your new form. No need to call show method.
}
If this helps you, please do not forget to mark this answer as accepted.
Lalit MRank #1,186 · 1.5K reputationPosted Nov 19, 2009, 6:43 PM EST
More Example might be help using Javascript.
jeevan mummadi140 reputationPosted Nov 19, 2009, 8:02 PM EST
Nilanka DharmadasaRank #1,875 · 794 reputationPosted Nov 19, 2009, 8:13 PM EST
Pls mark my answer as ACCEPTED if it helped you. It HELPS me.... :)
tripti kumbhat4 reputationPosted Mar 15, 2012, 9:50 AM EDT
it is working properly.
but can u explain me following line..
System.Threading.
Thread mythread = new System.Threading.Thread(new System.Threading.ThreadStart(OpenNewFrom));
VulpesRank #55 · 29.2K reputationPosted Mar 15, 2012, 10:56 AM EDT
This is necesssary because when this.Close() is called, the current user interface thread will terminate.
tripti kumbhat4 reputationPosted Mar 16, 2012, 6:16 AM EDT
Kapil Gahlot3 reputationPosted Apr 22, 2012, 12:01 AM EDT
Data db = new Data();
db._textBox = name;
db._textBox1 = currentFrame.Copy(f.rect).Convert
db._index = trainingImages.LastIndexOf(result) + 1;
db.Show();
stop_capture();
button1.Enabled = true;
I need to pass these values using threads...
Sam HobbsRank #107 · 20.5K reputationPosted Apr 22, 2012, 11:27 AM EDT
Also, Application.Run will create a new message loop and that is not necessary.
Please clarify one thing for me. Do you need to show the login form only once or do you need to allow the user to logout and then login again? If the former; if you need to show the login just once; then a good solution is to show the login form at the beinning of the program, in the Program class in the Program.cs file.
Perhaps the only thing you need to do differently in the code you had originally is to use ShowDialog instead of Show.
If you want the login form ot be modeless instead of modal, then a solution that I often use is to show and hide the other form; the login form instead of creating a new instance every time.
Actually, now that I think about it, I think the only problem with your original code is probably that you have the "this.Close()" in the wrong place. You need to have it in the Login form and you probably do not.
Please, let us first understand what you need to do before we try to suggest solutions. I think the requiremetns are not defined welll enough.
Sam HobbsRank #107 · 20.5K reputationPosted Apr 22, 2012, 11:42 AM EDT
Kapil, go ahead and create and create a new discussion for your question.
Vaibhav Pandey3 reputationPosted Jun 12, 2012, 2:38 AM EDT
That was really very Helpfulll.
yuvaraj prabhu2 reputationPosted May 18, 2015, 5:09 AM EDT