How to Remember username or password for login form

后端 未结 5 1357
囚心锁ツ
囚心锁ツ 2021-02-06 15:18

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 provid

5条回答
  •  野的像风
    2021-02-06 15:25

    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.

提交回复
热议问题