2021-07-29 BCB动态创建控件实例

动态创建控件的例子。

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

#include <vcl.h>
#pragma hdrstop

#include "wxpassUnit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
   TListBox *mlist[24];

   for(int k=0;k<24;k++)
   {
     mlist[k]=new TListBox(Form1);
   }
   mlist[0]=ListBox2;
   mlist[1]=ListBox3;
   mlist[2]=ListBox4;
   mlist[3]=ListBox5;
   mlist[4]=ListBox6;
   mlist[5]=ListBox7;
   mlist[6]=ListBox8;
   mlist[7]=ListBox9;
   mlist[8]=ListBox10;
   mlist[9]=ListBox11;
   mlist[10]=ListBox12;
   mlist[11]=ListBox13;
   mlist[12]=ListBox14;
   mlist[13]=ListBox15;
   mlist[14]=ListBox16;
   mlist[15]=ListBox17;
   mlist[16]=ListBox18;
   mlist[17]=ListBox19;
   mlist[18]=ListBox21;
   mlist[19]=ListBox22;
   mlist[20]=ListBox23;
   mlist[21]=ListBox24;
   mlist[22]=ListBox25;
   for(int k=0;k<23;k++)
   {
     mlist[k]->Items->Strings[10]=AnsiString(k);
   }
}
//---------------------------------------------------------------------------

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

moneytree

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值