开发者

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')
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜