delphi中combobox下拉选项点击无法在框中显示,而且点击后其他text里的内容也会清空 20
如图,获奖情况里选项重复,如点击国家三等选项后,不但没在框内显示,而且前面几个框里填好的内容也会清空,代码如下:procedureTbookinForm.FormActi...
如图,获奖情况里选项重复,如点击国家三等选项后,不但没在框内显示,而且前面几个框里填好的内容也会清空,代码如下:
procedure TbookinForm.FormActivate(Sender: TObject);
var
AdoTable1:TAdoTable;AdoTable2:TAdoTable;
begin
initiate;
adotable1:=TAdoTable.Create(self);
adotable1.Connection:=adoconnection1;
adotable1.TableName:='单位信息表';
adotable1.Open;
combobox1.Items.Clear;
while not adotable1.Eof do
begin
combobox1.Items.Add(adotable1.fieldbyname('单位名').asstring);
adotable1.Next;
end;
new:=false;
adotable2:=TAdoTable.Create(self);
adotable2.Connection:=adoconnection1;
adotable2.TableName:='教材表';
adotable2.Open;
combobox2.Items.Clear;
while not adotable2.Eof do
begin
combobox2.Items.Add(adotable2.fieldbyname('获奖情况').asstring);
adotable2.Next;
end;
new:=false;
end; 展开
procedure TbookinForm.FormActivate(Sender: TObject);
var
AdoTable1:TAdoTable;AdoTable2:TAdoTable;
begin
initiate;
adotable1:=TAdoTable.Create(self);
adotable1.Connection:=adoconnection1;
adotable1.TableName:='单位信息表';
adotable1.Open;
combobox1.Items.Clear;
while not adotable1.Eof do
begin
combobox1.Items.Add(adotable1.fieldbyname('单位名').asstring);
adotable1.Next;
end;
new:=false;
adotable2:=TAdoTable.Create(self);
adotable2.Connection:=adoconnection1;
adotable2.TableName:='教材表';
adotable2.Open;
combobox2.Items.Clear;
while not adotable2.Eof do
begin
combobox2.Items.Add(adotable2.fieldbyname('获奖情况').asstring);
adotable2.Next;
end;
new:=false;
end; 展开
2个回答
展开全部
.FormActivate,是窗体得到焦点时都要调用的,你可以加在OnShow()中,如果是加在onCreate中可能会报错,因为窗体的控件可能还没有创建完成。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询