序号的自动生成 1.定义变量 private maxno:integer; public bmodified:boolean; 2.写函数 function max(const a,b:integer):integer; begin if a>b then result:=a else result:=b; end; 3 FormCreate 中加入 bmodified:=false; while not adoq_rsinfo.eof do begin maxno:=max(maxno, adoq_rsinfo.fields[0].asinteger); adoq_rsinfo.next; end; 4。在你的添加按钮中加入 adoq_rsinfo.field[0].asinteger:=maxno+1;
同意gzllich(刚从泥坑里出来) 的方法。
1.定义变量
private
maxno:integer;
public
bmodified:boolean;
2.写函数
function max(const a,b:integer):integer;
begin
if a>b then
result:=a
else
result:=b;
end;
3 FormCreate 中加入
bmodified:=false;
while not adoq_rsinfo.eof do
begin
maxno:=max(maxno, adoq_rsinfo.fields[0].asinteger);
adoq_rsinfo.next;
end;
4。在你的添加按钮中加入
adoq_rsinfo.field[0].asinteger:=maxno+1;
请你和其他高手指点。
楼主,不好意思用了你的帖子问问题了,我想你可能也不知道,下次我问问题
你进来我给你分!!
这样不行的,RecNo这个东西并不是很确定,你把记录移到最后一条或者第一条RenNo都会改变
dbgrideh1.field[0].asinteger:=i
会抛异常不行压
2 在字段列表中右键,选 new field
3 在输入name 栏中输入任意的字段名字 ,type 选 integer
size 中输入最大长度如:20 fieldtype选择 calculated , 按 OK
4 再在字段列表中右键 ,点 add all fields
5 选中query1,在属性栏里选择 event 页
选择 OnClacFields 事件,编写代码如:
dataset.fieldbyname('你的计算字段').asinteger:=dataset.fieldbyname('你的计算字段').asinteger+1;
5 DbGrid 中显示该字段
2 在字段列表中右键,选 new field
3 在输入name 栏中输入任意的字段名字 ,type 选 integer
size 中输入最大长度如:20 fieldtype选择 calculated , 按 OK
4 再在字段列表中右键 ,点 add all fields
5 选中query1,在属性栏里选择 event 页
选择 OnClacFields 事件,编写代码如:
dataset.fieldbyname('你的计算字段').asinteger:=i+1; i是formcreate时初始化0的变量
5 DbGrid 中显示该字段
我试过可以实现
|国家|省级|其他|
这个表头是这样的,我一查出结果,现在只需要在输出时判断情况然后填写即可。关键是我不知道如何用dbgrideh来自己输入值