フォーム コンポーネントを列挙するのは非常に簡単です。
for (int i=0;i<ComponentCount;i++)
{
ShowMessage(Components[i]->Name);
//.....
}
ただし、パネルにあるコンポーネントのみを列挙したい場合、同じことは機能しません。
for (int i=0;i<Panel1->ComponentCount;i++)
{
ShowMessage(Panel1->Components[i]->Name);
//.....
}
なぜなら
Panel1->ComponentCount;
パネルにいくつかのコンポーネントがある間はゼロです。では、Panel の子コンポーネントを列挙するにはどうすればよいでしょうか。