need help to create log in form in visual studio , need some basic assistance

Recommended Answers

All 5 Replies

What have you tried for yourself so far?

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.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.