如何清除ScrollBox中的所有动态添加的TImage和TLabel
首先:
for(int i=0;i<5;i++)
{
TImage *img=new TImage(ScrollBox2);
img->Parent=ScrollBox2;
img->Width=220;
img->Height=175;
img->Left=10+(img->Width+50)*(i%3);
img->Top=10+(img->Height+40)*(i/3);
img->AutoSize=false;
img->Stretch=true;
img->Center=true;
img->Picture->LoadFromFile("d:\\mmm.bmp");
}
如上我在ScrollBox2上添加了5个image
然后我想删除所有的image,即让scrollbox恢复空白状态:我用如下代码
TComponent *Temp;
for (int I = ScrollBox2->ComponentCount - 1; I >= 0; I--)
{
Temp = ScrollBox2->Components[I];
ScrollBox2->RemoveComponent(Temp);
}
可是图象依然存在,不知道该如何操作?