線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:1401
推到 Plurk!
推到 Facebook!

新手請教COMBOBOX問題

答題得分者是:jow
cnnick
一般會員


發表:1
回覆:1
積分:0
註冊:2006-09-26

發送簡訊給我
#1 引用回覆 回覆 發表時間:2007-12-11 20:21:28 IP:122.100.xxx.xxx 訂閱
if not adoquery1.IsEmpty then
begin
tc:=tcombobox.Create(nil);
combobox1.Clear;
adoquery1.First;
while not adoquery1.Eof do
begin
tc.Items.Add(adoquery1.Fields[0].Asstring);
adoquery1.Next;
end;
combobox1:=tc;
end;


出錯:control has no parent window

請問各位高手出錯原因?
yubad2000
中階會員


發表:0
回覆:44
積分:78
註冊:2007-09-30

發送簡訊給我
#2 引用回覆 回覆 發表時間:2007-12-11 22:32:41 IP:66.171.xxx.xxx 未訂閱

You might need to attach this control object to a Form or Window by calling "tc:=tcombobox.Create(form1);"

===================引 用 cnnick 文 章===================
if not adoquery1.IsEmpty then
begin
tc:=tcombobox.Create(nil);
combobox1.Clear;
adoquery1.First;
while not adoquery1.Eof do
begin
tc.Items.Add(adoquery1.Fields[0].Asstring);
adoquery1.Next;
end;
combobox1:=tc;
end;


出錯:control has no parent window

請問各位高手出錯原因?
------
===波士頓夜未眠===
What a wonderful world!!
Jazz up the world with jazz!!
==================

When I am not programming...
you can find me here:
http://www.holy-war.de/EN/World3/bin/?advertiser=63190
jow
尊榮會員


發表:66
回覆:751
積分:1253
註冊:2002-03-13

發送簡訊給我
#3 引用回覆 回覆 發表時間:2007-12-12 15:12:05 IP:210.66.xxx.xxx 訂閱
操作資料(字串)不要用TComboBox, 請改用 TStringList
最後再顯示結果....

[code delphi]
procedure TForm1.Button1Click(Sender: TObject);
var
L: TStringList;
begin
if not AdoQuery1.IsEmpty then
begin
L := TStringList.Create;
try
AdoQuery1.First;
while not AdoQuery1.Eof do
begin
L.Add(AdoQuery1.Fields[0].Asstring);
AdoQuery1.Next;
end;
ComboBox1.Items.Text := L.Text;
finally
FreeAndNil(L);
end;
end;
end;
[/code]

===================引 用 cnnick 文 章===================
if not adoquery1.IsEmpty then
begin
tc:=tcombobox.Create(nil);
combobox1.Clear;
adoquery1.First;
while not adoquery1.Eof do
begin
tc.Items.Add(adoquery1.Fields[0].Asstring);
adoquery1.Next;
end;
combobox1:=tc;
end;


出錯:control has no parent window

請問各位高手出錯原因?
cnnick
一般會員


發表:1
回覆:1
積分:0
註冊:2006-09-26

發送簡訊給我
#4 引用回覆 回覆 發表時間:2007-12-12 22:41:54 IP:202.86.xxx.xxx 訂閱
多謝回覆!
問題解決了....thx!!!!!!!!!
系統時間:2024-04-27 11:04:46
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!