How to Remember username or password for login form

Smith picture Smith · Sep 22, 2012 · Viewed 27.7k times · Source

I have created a sample Login form in C# Windows Form Application and what I want is to add Remember username or password feature to my login form.

I just need to provide my username, cause it will remember my password and automatically fill in the password field (Ex. Like in gmail auth).

How could I achieve that?

This is my Login form app:- http://i50.tinypic.com/2pzxjb7.jpg

Answer

Lrodriguez84 picture Lrodriguez84 · Jul 27, 2016

I solved using that.

In you winforms project right click and go to properties, select settings and add name to store data (eg. userName and passUser)

So in you login form add a checkbox remember me.

In you button loggin check if checkbox true, save user and pass

        if (checkRemember.Checked)
        {
            Properties.Settings.Default.userName = textBoxUserName.Text;
            Properties.Settings.Default.passUser = textBoxUserPass.Text;
            Properties.Settings.Default.Save();
        }

In you load login form add this

        if (Properties.Settings.Default.userName != string.Empty)
        {
            textBoxUserName.Text = Properties.Settings.Default.userName;
            textBoxUserPass.Text = Properties.Settings.Default.passUser;
        }

Regards.