venus najad

venus najad

  • 1.3k
  • 414
  • 28.1k

Object reference not set to an instance of an object.

Aug 19 2024 2:43 AM

hello everyone, 

i try to fill a 2D paanel dynamically, but i receive this error:

Object reference not set to an instance of an object.

i have initilaized the controls and use following codes:

row=0, col=0;

 HtmlForm form2 = new HtmlForm();            
            Panel[,] panelAd = new Panel[mm, 3];
            Table mytable = new Table(); 

....

 mytable.Controls.Add(trow_7);

            if (col < 3)
            {
                panelAd[row, col].Controls.Add(mytable);
                this.form2.Controls.Add(panelAd[row, col]);
                col++;
            }
            else
            {
                row++;
                col = 0;
                panelAd[row, col].Controls.Add(mytable);
                this.form2.Controls.Add(panelAd[row, col]);
            }
            

how should i fix it? appreciate your resspond with codes, kind regards

 


Answers (8)