请问如何动态的创建,并显示控件

demonlwg1980124 2003-04-17 01:09:15
代码如下:
//*.h
public:
TButton *Button2;
//*.cpp
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
Button2=NULL;
}
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Button2= new TButton(Form1);
Button2->Width=25;
Button2->Top=200;
Button2->Height=40;
Button2->Caption="new";
Button2->Visible=true;
Button2->Show();
}
但结果却没有显示。请问各位高手,怎么样去解决呢?谢谢啦!!
...全文
21 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
sbbmu 2003-04-17
  • 打赏
  • 举报
回复
Button2->Parent=this; //一定要有,否则不会显示
pp616 2003-04-17
  • 打赏
  • 举报
回复
Button2->Parent=this;
Button2->Show();

13,822

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧