加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

如何在delphi中动态创建组件,如TLabel或TEdit等

发布时间:2020-12-15 04:34:36 所属栏目:大数据 来源:网络整理
导读:使用Delphi 2010 SQLQuery1.First; // move to the first recordwhile(not SQLQuery1.EOF)do begin // do something with the current record // What's the code should i write in this part in order to create a TEdit // containing the user fullname
使用Delphi 2010
SQLQuery1.First; // move to the first record
while(not SQLQuery1.EOF)do begin
   // do something with the current record
   // What's the code should i write in this part in order to create a TEdit
   // containing the user fullname the current item.
   ShowMessage(SQLQuery1['whom']);
   SQLQuery1.Next; // move to the next record
end;

解决方法

好吧,要创建一个TEdit,您需要执行以下操作:

创建一个可以使用的变量.局部变量或类成员.

Edit: TEdit;

然后你构建它.

Edit := TEdit.Create(Self);

构造函数的参数是所有者.这可确保在销毁其所有者时销毁该控件.我的假设是自我是一种形式.

现在你需要给控件一个父级.

Edit.Parent := Self;

或者也许是在面板上.

Edit.Parent := StatusPanel;

最后,设置文本.

Edit.Text := SQLQuery1['whom']);

除了使用Caption属性而不是Text属性之外,使用标签它们都非常相似.

你一定会想要设置其他属性,但我想你已经知道如何做到这一点.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读