jedbartlet
Member
Im trying to display a number of panels on a form. The number of panels is determined by the user. I would like to create the panels dynamicly. The code i came up with is as follows:
void MainForm1::setLayout(int no_boxes)
{
Panel *box[];
for(int i=0; i<=boxes; i++)
{
box = new Panel();
box->BorderStyle = BorderStyle::FixedSingle;
//more properties set here....
}
this->SuspendLayout();
this->tsetGbox->Controls->AddRange(box);
this->ResumeLayout();
}
When i run the app i get the following error message at runtime:
Object reference not set to an object instance.
Am i forgetting to use the this pointer somewhere or is it something else. Im relatively new to visual C++ in case you cant allready tell! Any help apreciated.
void MainForm1::setLayout(int no_boxes)
{
Panel *box[];
for(int i=0; i<=boxes; i++)
{
box = new Panel();
box->BorderStyle = BorderStyle::FixedSingle;
//more properties set here....
}
this->SuspendLayout();
this->tsetGbox->Controls->AddRange(box);
this->ResumeLayout();
}
When i run the app i get the following error message at runtime:
Object reference not set to an object instance.
Am i forgetting to use the this pointer somewhere or is it something else. Im relatively new to visual C++ in case you cant allready tell! Any help apreciated.