应该用dbComboBox或者DbLookupComboBox
解决方案 »
- DLL回调函数,无法正常调用,不知道哪出错了[100分求解]
- DLL组件中函数的使用方法?再开贴!
- 急用,谢谢哪位朋友帮忙解决。
- 寻求 解决方案哦 sql语句的问题 (在线等待)
- 请兄弟们给估个价钱,我自己接的私活
- 关于TTreeView查找节点的问题
- 如何使datetimepicker返回的值只有4位年和两位月
- 冰雪跪求:wopti将视频加密后无法正确解密
- form的close事件结束后,跳到了form的一段不相关的procedure处,由于form已经free了,所以报地址错,检查过了,程序没有错,配置文件也重
- 连接SQL服务器出现的问题!!??
- 如何在ComboBox中显示图片
- delphi中dbexpress 与bde ado 有什么区别!!!!!欢迎讨论各自的优缺点
uses
db,dbclient,stdctrls,classes,Sysutils,Dialogs;
procedure GetComboBoxList(DataSet:TDataSet;FieldName:string;ComboBox:TComboBox);
implementationprocedure GetComboBoxList(DataSet:TDataSet;FieldName:string;ComboBox:TComboBox);
{本过程为目标ComboBox加载数据源DataSet中
字段名为FieldName的所有数据项的list列表}
var
StringList: TStrings;
FieldValue:string;
begin
if DataSet.Fields.FindField(FieldName) = nil then
begin
showmessage('错误:指定字段'+FieldName+'没找着!');
exit;
end;
StringList := TStringList.Create;
try
with DataSet do
begin
if not active then open;
first;
while not eof do
begin
FieldValue:=trim(FieldByName(FieldName).asstring);
StringList.Add(FieldValue);
next;
end;
first;
end;
with ComboBox do begin
Width := 210;
Items.Assign(StringList);
ItemIndex := 0;
ComboBox.Style:=csDropDownList;
end;
finally
StringList.free;
end;
end;end.