使用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属性之外,使用标签它们都非常相似.
你一定会想要设置其他属性,但我想你已经知道如何做到这一点.