private void Login_page()
        {
            var i = 0;
            while (i < 5)
            {
                if (textBox1.Text.Equals("admin"))
                {
                    if (textBox2.Text.Equals("parth"))
                    {

                    }
                    else
                    {
                        textBox1.ResetText();
                        MessageBox.Show("passwod is wrong try agine");
                        i++;

                    }
                }
                else
                {
                    textBox2.ResetText();
                    MessageBox.Show("username and password is wrong");
                    i++;

                }
            }
            if (i == 5)
            {

                MessageBox.Show("you tried max time");
                Dispose();
            }
            else
            {
                MainMenu mainMenu = new MainMenu();
                mainMenu.Show();
                this.Hide();
            }
        }

I am tring for if inserted password and username is wrong so its give 5 time to change that but i have proble how to insert text next time in textbox. in this code loop is continusly insert blank text in textbox. so how to fix it??

Look at the else clauses of your if statements and switch textBox1 with textBox2. Your are testing one textbox and clearing the other!

private int Login_page(int i)
        {
            if (textBox1.Text.Equals("admin"))
                {
                    if (textBox2.Text.Equals("parth"))
                    {
                        MainMenu mainMenu = new MainMenu();
                        mainMenu.Show();
                        this.Hide();
                        return 0;
                    }
                    else
                    {
                        textBox2.Clear();
                        MessageBox.Show("passwod is wrong try agine");
                        if (i == 5)
                        {
                            MessageBox.Show("you tried max time");
                            Dispose();  
                        }
                        return i++;
                    }
                }
                else
                {
                    textBox1.Clear();
                    MessageBox.Show("username and password is wrong");
                    if (i == 5)
                    {
                        MessageBox.Show("you tried max time");
                        Dispose();
                    }
                    return i++;

                }

now its working..
Thank you sir..

This question has already been answered. Start a new discussion instead.