在dbgrid中,我添加一个计算字段,然后在计算事件中,对该计算字段赋值。
我这里是将RecordNo赋给该字段,但是奇怪的问题出现了在第一行竟然显示出来的是-1,接下来时2、3...,但是如果我对某行数据修改,post后第一行的RecordNo将变成1,怪不而且我用
Adotable1.first;
showmessage((inttostr(adotable1.recordno));
显示的也是1
我这里是将RecordNo赋给该字段,但是奇怪的问题出现了在第一行竟然显示出来的是-1,接下来时2、3...,但是如果我对某行数据修改,post后第一行的RecordNo将变成1,怪不而且我用
Adotable1.first;
showmessage((inttostr(adotable1.recordno));
显示的也是1
NumberLabel1.Caption:='1';
begin
//ADOTable1.First;
//ADOTable1.FieldByName('recordno').AsString :=inttostr(StrtoInt(ADOTable1.FieldByName('bianhao').asstring)+StrToInt(ADOTable1.FieldByName('jiner').AsString));
ADOTable1.FieldByName('recordno').AsString := inttostr(ADOTable1.Recno);
if adotable1.RecNo<0 then
ADOTable1.FieldByName('recordno').AsString:='1';
end;
这样就可以了!
begin
ADOTable1.FieldByName('recordno').AsString := inttostr(ADOTable1.Recno);
if adotable1.RecNo<0 then
ADOTable1.FieldByName('recordno').AsString:='1';
end;
不好意思发错了!