MainForm....
private void MainForm_Load(object sender, EventArgs e)
{
LoginForm log = new LoginForm();
log.ShowDialog();
if (log.DialogResult == DialogResult.OK)
{
label1.Text = log.textBox1.Text;//用户名
label2.Text = log.textBox2.Text;//密码
}
}
LoginForm....
private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text == "abc" && textBox2.Text == "123")
this.DialogResult = DialogResult.OK;
else
MessageBox.Show("用户名或密码有误!");
}