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
yuvaraj prabhuPosted May 18, 2015, 9:09 AM
Vaibhav PandeyPosted Jun 12, 2012, 6:38 AM
That was really very Helpfulll.
Sam HobbsPosted Apr 22, 2012, 3:42 PM
Kapil, go ahead and create and create a new discussion for your question.
Sam HobbsPosted Apr 22, 2012, 3:27 PM
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.
Kapil GahlotPosted Apr 22, 2012, 4:01 AM
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...
tripti kumbhatPosted Mar 16, 2012, 10:16 AM
VulpesPosted Mar 15, 2012, 2:56 PM
This is necesssary because when this.Close() is called, the current user interface thread will terminate.
tripti kumbhatPosted Mar 15, 2012, 1:50 PM
it is working properly.
but can u explain me following line..
System.Threading.
Thread mythread = new System.Threading.Thread(new System.Threading.ThreadStart(OpenNewFrom));
Nilanka DharmadasaPosted Nov 20, 2009, 1:13 AM
Pls mark my answer as ACCEPTED if it helped you. It HELPS me.... :)
jeevan mummadiPosted Nov 20, 2009, 1:02 AM
Nilanka DharmadasaPosted Nov 19, 2009, 11:49 PM
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 MPosted Nov 19, 2009, 11:43 PM
More Example might be help using Javascript.