Object reference not defined, what could it be?

-2

"

"

"

Button[,] botoes = new Button[(int)numericUpDownLinhas.Value, (int)numericUpDownColunas.Value];
    for(int i = 0; i < (int)numericUpDownLinhas.Value; i++)
    {
        for(int j = 0; j < (int)numericUpDownColunas.Value; j++)
        {
            botoes[i, j].BackColor = button1.BackColor;
            botoes[i, j].Size = new Size((int)numericUpDownX.Value, (int)numericUpDownY.Value);
            botoes[i, j].Location = new Point(18 + j * ((int)numericUpDownX.Value + 4), 35 + i * ((int)numericUpDownY.Value + 4));
            this.Controls.Add(botoes[i, j]);
        }
    }

Of the error in these 3 lines:

botoes[i, j].BackColor = button1.BackColor;
botoes[i, j].Size = new Size((int)numericUpDownX.Value, (int)numericUpDownY.Value);
botoes[i, j].Location = new Point(18 + j * ((int)numericUpDownX.Value + 4), 35 + i * ((int)numericUpDownY.Value + 4));

Would anyone know why?

    
asked by anonymous 06.08.2016 / 16:34

1 answer

0

I solved it! Before the three lines mentioned I put the following: botoes[i, j] = new Button();

    
06.08.2016 / 18:44