这是delphi一贯的做法,向我以前用惯了vfp,也很不适应。
这段程序应该自己写。
with ADOQuery1 do
begin
active:=false;
sql.Clear;
sql.Add('select id from table1);
open;
if RecordCount>0 then
begin
first;
for i:=0 to RecordCount-1 do
begin
str:=Fields.Fields[0].Value;
dbcombobox1.Items.add(str);
Next;
end;
end;
end;
str为字符型,在var 中定义
var
str:string;这样做之后,
如果数据源也指定,在程序中dbcombobox1既可以显示当前的字段的值,也可以运行时下拉有其他的纪录
这段程序应该自己写。
with ADOQuery1 do
begin
active:=false;
sql.Clear;
sql.Add('select id from table1);
open;
if RecordCount>0 then
begin
first;
for i:=0 to RecordCount-1 do
begin
str:=Fields.Fields[0].Value;
dbcombobox1.Items.add(str);
Next;
end;
end;
end;
str为字符型,在var 中定义
var
str:string;这样做之后,
如果数据源也指定,在程序中dbcombobox1既可以显示当前的字段的值,也可以运行时下拉有其他的纪录
解决方案 »
- 帮我看看函数为什么编译不过去。
- 请问有人能帮我写一个数组转化成一个字符串
- 使用 TServerSocket 与 TClientSocket 如何实现广播或组播传输? 在线等, UP有分
- 请问一个文件操作的问题
- imail 不能发送邮件,谁能告知原因?(在线等待)
- 如何在程序中调用存储过程
- 一个关于打印的问题,请教!
- 哪位大师能提供我一个操作系统中生产者-消费者问题的演示程序,很急!帮帮忙
- 我做的东西怎么打包作成安装程序啊。
- 关于COM技术
- 如何设置字型?立即给分?(up有分)
- 請教delphi幫助中這句話是什麼意思?? Copy(Text,1,SelStart)+Copy(Text,SelLength+SelStart+1,255)
类似的还有DBGrid中的下拉框。
with talble1 do
begin
active:=false;
open;
if RecordCount>0 then
begin
first;
while not table1 eof do
begin
dbcombobox1.Items.add(Fields.Fields[n].Value);//n指代所用的字段,从0开始。
next;
end;
end;
end;
如果用作动态处理,可以动态给talble1指定链接的表。
with talble1 do
begin
active:=false;
open;
if RecordCount>0 then
begin
first;
while not table1 eof do
begin
dbcombobox1.Items.add(Fields.Fields[n].Value);//n指代所用的字段,从0开始。
next;
end;
end;
end;
如果用作动态处理,可以动态给talble1指定链接的表。
begin
close;
sql.Clear;
sql.Add('select number from xsgl..xsjbxx');
open;
first;
while not eof do
begin
dbcombobox1.Items.Add(adoquery1.fieldbyname('number').asstring);
next;
end;
end;
begin
close;
sql.Clear;
sql.Add('select number from xsgl..xsjbxx');
open;
first;
while not eof do
begin
dbcombobox1.Items.Add(adoquery1.fieldbyname('number').asstring);
next;
end;
end;
还有就是delphi中的函数名等标识符的名称太长了,不好记,帮助系统也有大好,明显的举个例子:with...do....起码VB中就可以用一个'。'号自动引出属性列表窗;VB的explicit语句又可以变量的大小写得以统一看起来方便。不知大伙对delphi的感受如何,说来大家讨论一下吧!