|
VisualBasic(VB)では、Formの上に置いたコントロールを配列のように扱う事がプロパティの設定だけで簡単に行う事ができます
ところがC++Builderではちょっと手順を踏む必要があります
いくつか方法がありますが、ここではその内の一つについて説明します
class Form : public TMForm {
private:
TLabel **lblName;
}
lblName = new TLabel[n];
for (int intLoop=0;intLoop<n;intLoop++) {
lblName[intLoop] = new TLabel;
lblName[intLoop]->Parent = Form;
lblName[intLoop]->Left = xxxx;
lblName[intLoop]->Top = xxxx;
lblName[intLoop]->Width = xxxx;
lblName[intLoop]->Height = xxxx;
lblName[intLoop]->Caption = xxxx;
}
例ではTLabelの配列を作成しています
new で作成しただけでなく、位置など必要なプロパティも全てプログラム中で指定する必要があります
|