编程语言
首页 > 编程语言> > C# Winform 简单的登录窗体实现

C# Winform 简单的登录窗体实现

作者:互联网

后台代码:

public FormLogin()
{
    InitializeComponent();

    MinimizeBox = false;
    MaximizeBox = false;
    FormBorderStyle = FormBorderStyle.FixedSingle;

    textBox2.UseSystemPasswordChar = true;
    textBox2.PasswordChar = '*';
}

private void button1_Click(object sender, EventArgs e)
{
    if (textBox1.Text == "abc" && textBox2.Text == "abc")
    {
        DialogResult = DialogResult.OK;
    }
    else
    {
        MessageBox.Show("用户名或密码错误");
    }
}

Program.cs

[STAThread]
static void Main(string[] args)
{
    Application.EnableVisualStyles();
    Application.SetCompatibleTextRenderingDefault(false);
    FormLogin formLogin = new FormLogin();

    if (formLogin.ShowDialog() == DialogResult.OK)
    {
        Application.Run(new FormMain());
    }
}



我的微信公众号:

标签:false,C#,formLogin,DialogResult,Application,textBox2,窗体,FormLogin,Winform
来源: https://www.cnblogs.com/huvjie/p/14979889.html