HAI,
I AM DEVELOPING WINDOWS APPLICATION IN VB.NET IN MY PROJECT I WANT OPEN ONE FORM WHEN THE LOGIN IS SUCCESS BUT LOGIN FORM IS STILL ALIVE I WANT CLOSE THAT LOGIN FORM AS WELL AS OPEN THE OTHER FORM WHAT IS THE SOLUTION GIVE THE RIGHT SUGGESTION IF ANY ONE HAVE IDEA ON WINDOWS APPLICATION
Loading

Mamta MRank #268 · 9.4K reputationPosted Jul 26, 2010, 3:33 AM EDT
-Mamta
Hiren SoniRank #694 · 3.5K reputationPosted Jul 26, 2010, 3:35 AM EDT
or
you can do onething.
in main form( means page which opens after successful login).
you can take one bool variable loggedin.
in that form_load you can check whether the user has logged in or not using loggedin variable.
if not then open login window. and if user entered valid username and password then assign one variable "loggedin = true " in the main form.
if user entered wrong password then ask user to enter valid password or you can exit from the application.
---------
dont forget to accept answer, if it helps you.
DMR Santosh14 reputationPosted Jul 26, 2010, 4:24 AM EDT
You can do like this ::
this.Hide();
Form f = new Form();
f.Show();
under the button click
then the form1 will hide and shows you the new form, when you want to close the form
then you can write as Application.close();
Regards,
D.M.R.Santosh
DMR Santosh14 reputationPosted Jul 26, 2010, 4:41 AM EDT
private void button1_Click(object sender, EventArgs e)
{
this.Hide();
Form f = new Form();
f.Show();
f.FormClosed += new FormClosedEventHandler(f_FormClosed);
}
void f_FormClosed(object sender, FormClosedEventArgs e)
{
Application.Exit();
}
Regards,
D.M.R.Santosh
Koteswararao MallisettiRank #2,740 · 511 reputationPosted Jul 26, 2010, 4:55 AM EDT
Hiren SoniRank #694 · 3.5K reputationPosted Jul 26, 2010, 5:13 AM EDT
Tomasz Kornacki22 reputationPosted Jul 29, 2010, 5:24 AM EDT
public partial class MainForm: Form
{
LoginForm f;
object customData;
public MainForm()
{
f = new LoginForm();
f.ShowDialog(this);
objectCustomData = f.CustomProperty;
InitializeComponent();
}
}
And after succesfull login you should call this.Close() inside LoginForm. To collect data from LoginForm (like login information) define as many properties as you need.
Cheers
Tomek K.