要用Combobox类读取数据库中的某个字段中某些值作为combobox类的items,有什么好方法?help me

fangzhouyu 2003-05-12 10:31:32
如题,急需,combobox,dbcombobox,lookupcombobox都可以,我都用过,没有成功过,那位大佬有好的方法?
...全文
29 点赞 收藏 17
写回复
17 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
lf43 2003-05-14
为什么不用DBLOOKUPCOMBOBOX呢
DBLOOKUPCOMBOBOX.keyvalue=query1.fieldbyname('field').asstring
回复
chao_jian 2003-05-14
方法基本都列出来了,好好选一个!
回复
snake_eye 2003-05-14
读进去:
FieldComboBox.Items.AddObject(Fields[I].DisplayLabel,Fields[I]);

要用的时候:
var
CurField:TField;
CurField:=TField(FieldComboBox.Items.Objects[FieldComboBox.ItemIndex]);

这下知道了吧!
回复
fangzhouyu 2003-05-13
snake_eye(★蛇眼★上帝派来灌水的人): 可不可以注释一下?^-^
回复
snake_eye 2003-05-13
昨天晚上我回复这贴子,怎么也回复不了,csdn 老出问题!
回复
snake_eye 2003-05-13
FieldComboBox.Items.AddObject(Fields[I].DisplayLabel,Fields[I]);
是关键!
回复
snake_eye 2003-05-13
procedure TQueryBilForm.SetEyeDataSet(ADataSet: TClientDataSet);
var
I:Integer;
begin
if FieldComboBox.Items.Count<>0 then
FieldComboBox.Items.Clear;
FEyeDataSet:=ADataSet;
for I:=0 to FEyeDataSet.FieldCount-1 do
FEyeDataSet.Fields[I].DisplayLabel:=FieldList[I];
with FEyeDataSet do
begin
for I:=0 to FEyeDataSet.FieldCount -1 do
begin
if not Fields[I].Visible then Continue;
if not CanFilter(Fields[I]) then Continue;
FieldComboBox.Items.AddObject(Fields[I].DisplayLabel,Fields[I]);
end;
end;
FFilterStr:='';
end;
回复
fangzhouyu 2003-05-13
我用的是socket连接的,用clientdataset,我是要从一个表中取出某些记录的同一个字段的值作为combobox的items,
回复
xlxfjxm 2003-05-13
同意楼上的
回复
chwdong 2003-05-13
if ADOQuery6.Active=true then ADOQuery6.Close;
ADOQuery6.SQL.clear;
ADOQuery6.sql.add('select * from tab_kmmc order by c1');
adoquery6.open;
ComboBox1.Items.Clear;
if ADOQuery6.RecordCount>0 then
begin
for i:=1 to ADOQuery6.RecordCount do
begin
ADOQuery6.RecNo:=i;
ComboBox1.Items.Append(adoquery6.findfield('c1').asstring);
end;
end
回复
bestluo 2003-05-13
combobox.items[i]
即可
回复
ytwxw 2003-05-13
你把问题说清楚点
我理解的是你想:
将某个字段的值读取出来作为combobox的item吗?
这个肯定很好实现啊 稍微懂点vcl与数据库都可以实现
回复
fangzhouyu 2003-05-13
up
回复
fangzhouyu 2003-05-13
up
回复
snake_eye 2003-05-12
if FieldComboBox.Items.Count<>0 then
FieldComboBox.Items.Clear;
FEyeDataSet:=ADataSet;
for I:=0 to FEyeDataSet.FieldCount-1 do
FEyeDataSet.Fields[I].DisplayLabel:=FieldList[I];
with FEyeDataSet do
begin
for I:=0 to FEyeDataSet.FieldCount -1 do
begin
if not Fields[I].Visible then Continue;
if not CanFilter(Fields[I]) then Continue;
FieldComboBox.Items.AddObject(Fields[I].DisplayLabel,Fields[I]);
end;
end;
FFilterStr:='';
回复
snake_eye 2003-05-12
if FieldComboBox.Items.Count<>0 then
FieldComboBox.Items.Clear;
FEyeDataSet:=ADataSet;
for I:=0 to FEyeDataSet.FieldCount-1 do
FEyeDataSet.Fields[I].DisplayLabel:=FieldList[I];
with FEyeDataSet do
begin
for I:=0 to FEyeDataSet.FieldCount -1 do
begin
if not Fields[I].Visible then Continue;
if not CanFilter(Fields[I]) then Continue;
FieldComboBox.Items.AddObject(Fields[I].DisplayLabel,Fields[I]);
end;
end;
FFilterStr:='';
回复
snake_eye 2003-05-12
if FieldComboBox.Items.Count<>0 then
FieldComboBox.Items.Clear;
FEyeDataSet:=ADataSet;
for I:=0 to FEyeDataSet.FieldCount-1 do
FEyeDataSet.Fields[I].DisplayLabel:=FieldList[I];
with FEyeDataSet do
begin
for I:=0 to FEyeDataSet.FieldCount -1 do
begin
if not Fields[I].Visible then Continue;
if not CanFilter(Fields[I]) then Continue;
FieldComboBox.Items.AddObject(Fields[I].DisplayLabel,Fields[I]);
end;
end;
FFilterStr:='';
回复
相关推荐
发帖
网络通信/分布式开发
创建于2007-08-02

1573

社区成员

Delphi 网络通信/分布式开发
申请成为版主
帖子事件
创建了帖子
2003-05-12 10:31
社区公告
暂无公告