验证用户名和密码用到dialogreault属性

    xiaoxiao2024-10-28  80

    主对话框:

    private void button1_Click(object sender, EventArgs e) { dialogresult dr = new dialogresult(); if (dr.ShowDialog() == DialogResult.OK) { MessageBox.Show("用户名和密码正确!"); } }

    弹出对话框

    private void button1_Click(object sender, EventArgs e) { if (textBox1.Text == "baobingji" && textBox2.Text == "123") { this.DialogResult = DialogResult.OK; this.Close(); } else { if (textBox1.Text != "baobingji") { textBox1.Text = string.Empty; } if (textBox2.Text != "123") { textBox2.Text = string.Empty; } } } private void button2_Click(object sender, EventArgs e) { this.Close(); }

    最新回复(0)