8
Answers

Object reference not set to an instance of an object.

Photo of venus najad

venus najad

Aug 19
553
1

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)