Check a username in a login form
I want the program checks if a specific name is typed(for example 'admin').If it is typed correctly i want to proceed on another form.I have this code but it turns me an error:
private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text = 'admin')
{
this.Hide();
// Show another form.
Form3 f2 = new Form3();
f2.ShowDialog(this);
}
}
please use this
if (textBox1.Text == "admin")
{
this.Hide();
// Show another form.
Form3 f2 = new Form3();
f2.ShowDialog(this);
}
I think you want
private void button1_Click(object sender, EventArgs e) {
if (textBox1.Text.Equals("admin"))
{
this.Hide();
// Show another form.
Form3 f2 = new Form3();
f2.ShowDialog(this);
}
}
I don't do Windows Forms development, but it might be this line of code:
if (textBox1.Text = 'admin')
should be
if (textBox1.Text == 'admin')
精彩评论