假設你現在要移除所有TPanel上的所有TImage,
可是使用for Loop去列出所有component,但是要注意,必須「由後往前」的去做移除,不然會發生問題
// 刪除(注意!! 要「由後往前」刪除)
for ( int i = ComponentCount-1; i>=0; --i ) {
TImage*pImg = dynamic_cast(Components[i]); if ( pImg !=NULL ) RemoveComponent(pImg); delete pImg;
}
}
ref:http://www.programmer-club.com.tw/ShowSameTitleN/cb/11065.html