Hello.
I am making an application that has restricted access. It is just simple.
I have an main form that where everything happens. So i just need user to type in the password to get in.
I thought just to make an window with masked textbox and button. And behind button this code:
if (maskedbutton.text == "password")
{
mainform.show();
}
else
system.close();
It does not need to be any more difficult then that. But this does not work so i need help. I cant get to my mainform from my login window and I need help with my code to close my form if password is wrong.
I have done this before and this code worked....but now now.
Do you have any suggestions

Make an login windows in app.
guywwe
Application.Run( new LoginForm() );
In LoginForm:
private btnLogin_Click( sender ...... )
{
if( txtPassword.Text == "SomeSecretPassword" )
{
MainForm mForm = new MainForm();
mForm.Show();
this.Close();
}
else
{
MessageBox.Show( "Illegal password!" );
txtPassword.Focus();
}
}
It should work.
Laurent67
hi.,
I think you should do like this:
Application.Run(new MainForm());
In the MainForm:
private MainForm_Load(sender ......)
{
}
In the LoginForm:
private btnLogin_Click(sender... )
{
}
private btnCancel_Click(sender...)
{
}
After you login, you don't need the LoginForm. So I usually first load MainForm and then show LoginForm. If user can login, just close the login form. If can't, just exit the application.
cheers..
soemoe
Blue The Dog
this kind of works.
but I have two problems...
1) mForm in your code does not close when password is correct...(this.Close(); should close it )
2) how to remove close, maximize and minimize buttons of the loginscreen
thank you for your help
Mystagogue
Thanks.
This helped alot:)
Shalin Dalal
2. If you want to hide all buttons, set ControlBox to False in Form properties. You can set it to True and set MaximizeButton and MinimizeButton to False, because it's better choice. If user won't write down password, he has to have a chance to close appliaction.