Hello, I have a slight problem

1

I write this code, but at the time of execution, it tells me an error, it says that this function is dedeclared but it is not used .... why is this error?

private void Button1_Click(object sender, EventArgs e)
            {
                if (textBox1.Text == "samara" && textBox2.Text == "12345")
                {
                    Form2 llamar = new Form2();
                    llamar.Show();
                }
                if (textBox1.Text == "carrico" && textBox2.Text == "67890")
                {
                    Form2 llamar = new Form2();
                    llamar.Show();
                }
                else {
                    MessageBox.Show("usuario incorrecto");
                }
    
asked by EricJovan 28.11.2018 в 03:28
source

1 answer

0

The reason why it is declared but not used is because it is not assigned to any event. To assign an event you can do it for example:

Button b = new Button();
// Asignandole al evento Click de un boton
b.Click = Button1_Click;

Or a button previously created from the designer. This is done by selecting the button in the design view and in the properties window select the events tab and in the Click event display the list and choose "Button1_Click"

This usually happens when you create an event from the designer and accidentally or intentionally delete it, and the generated function remains

    
answered by 30.11.2018 в 23:00