Danymic Label in GroupBox
-
Habe folgendes Probelm:
Ich erstelle ein dynamisches Array mit TLabels und möchte die nun in einer GroupBox anzeigen, wie kann ich die nun in die GroupBox einfügen?
-
In dem du die Parent-Eigenschaft entsprechend setzt.
-
void __fastcall TForm1::Button1Click(TObject *Sender) { // Counter static int count; // Groupbox erstellen TGroupBox* gb=new TGroupBox(Form1); gb->Parent=Form1; gb->Width=300; gb->Height=150; gb->Left=8; gb->Top=8+count*gb->Height; gb->Caption="GroupBox "+IntToStr(++count); // 10 Labels in Groupbox schreiben TLabel* l[10]; for(int i=0;i<10;++i) { l[i]=new TLabel(Form1); l[i]->Parent=gb; l[i]->Left=8; l[i]->Top=16+i*12; l[i]->Caption="Label "+IntToStr(i+1); } }
-
Hat geklapt, thanks