C++Builder Tips


フォーム・コントロールの列挙


フォームに配置されているコントロールを列挙するサンプルです。


//---------------------------------------------------------------------------

void __fastcall TForm1::FormCreate(TObject *Sender)
{
  int i;

  ListView1->Items->Clear();
  for (i=0;i<Form1->ComponentCount;i++){
    ListView1->Items->Add()->Caption = Form1->Components[i]->Name;
    ListView1->Items->Item[i]->SubItems->Add(Form1->Components[i]->ClassName());
  }
}
//---------------------------------------------------------------------------

DownLoad bcbtips060.lzh 3KB(BCB5)