5
Contributors
5
Replies
36
Views
3 Years
Discussion Span
Last Post by waqassilat
0

A simple way for a windows form. Create the form(LoginForm) with the textboxes, set the password mask on one of them, and labels you want, an OK button and a Cancel button.

In the LoginForm properties set the Accept Button and Cancel Button properties appropriately.

Double-click the OK button to add the event handler, and see the code stub. In here you do validation of the inputs from the textboxes. If the validation is good set the DialogResult property of the login form to DialogResult.OK. If it fails set the DialogResult to DialogResult.Cancel.

In your calling form, declare a form of your login form type(i.e. LoginForm NewLogin = new LoginForm();)

Declare a result variable of type DialogResult. Initialize it with the ShowDialog() method of the new login form(i.e. DialogResult Result = NewLogin.ShowDialog();). If the result is OK the login is valid.

If you need the login username to be persistent, you can use a global variable, and set it in the login form.

Edited by tinstaafl

0

oops ran out of time. I uploaded a template. If you copy the zip file to My Documents\Visual Studio 2010\Templates\Item Templates, it will load into your new items list. One thing I overlooked was setting the password mask.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.