實作 TDataLink 以取得資料筆數和目前在第幾筆時,發生錯誤 |
尚未結案
|
webber
初階會員 發表:54 回覆:76 積分:26 註冊:2004-04-20 發送簡訊給我 |
文後是小弟 實作 TDataLink 的原始碼
目的是取得資料總筆數和目前在第幾筆 但是在關閉Form時
procedure TDataLinkWebber.modifyRecordIndexControl();
中的
(self.gControlRecordIndex as TLabel).Caption:=self.getRecordIndexStr;
這行程式碼經常會有「EinvalidPoint - Invalid Point Operation」的錯誤,
用try except也沒有辦法略過錯誤 不知道那位前輩可以指點一二
感激不盡! unit DataLinkWebber; interface uses
SysUtils, Classes,DB,Dialogs,Controls,StdCtrls; type
TDataLinkWebber = class(TDataLink)
private
{ Private declarations }
giRecno:Integer;
giRecordCount:Integer;
gControlRecordIndex :TControl;
protected { Protected declarations }
public
{ Public declarations }
RecordIndexType:Integer; function getRecno:integer;
function getRecordIndexStr:String;
property RecordIndexStr: String read getRecordIndexStr;
property recno: integer read getRecno;
procedure DataSetScrolled(Distance: Integer) ;override;
procedure DataSetChanged;override;
procedure ActiveChanged;override; function getRecordIndexControl:TControl;
procedure setRecordIndexControl(pRecordIndexControl: TControl);
property RecordIndexControl: TControl read getRecordIndexControl write setRecordIndexControl;
procedure modifyRecordIndexControl();
procedure AfterConstruction() ;override; published
{ Published declarations }
end; implementation
procedure TDataLinkWebber.AfterConstruction; begin
self.giRecno:=-1;
self.giRecordCount:=-1;
end; function TDataLinkWebber.getRecordIndexControl:TControl;
begin
result:=gControlRecordIndex;
end;
procedure TDataLinkWebber.setRecordIndexControl(pRecordIndexControl: TControl);
begin
gControlRecordIndex:=pRecordIndexControl;
modifyRecordIndexControl();
end; function TDataLinkWebber.getRecordIndexStr:String;
begin if self.DataSet.Active then begin
result:='' inttostr(self.recno) ' / ' inttostr(self.DataSet.RecordCount) ''; end;
end; function TDataLinkWebber.getRecno:integer;
begin
result:=giRecno;
end;
procedure TDataLinkWebber.ActiveChanged;
begin
try if self.Active then begin
if giRecno=-1 then begin
giRecno:=1;
end; if self.DataSource<>nil then begin
if giRecordCount=-1 then begin
self.DataSet.Last;
self.DataSet.First;
giRecordCount:=self.DataSet.RecordCount;
end;
end;
end else begin
giRecordCount:=-1;
giRecno:=-1;
end;
modifyRecordIndexControl();
except
on E : Exception do
begin end;
end;
end;
procedure TDataLinkWebber.modifyRecordIndexControl();
begin
try if self.gControlRecordIndex<>nil then begin
if (self.gControlRecordIndex is TEdit) then
begin
(self.gControlRecordIndex as TEdit).Text :=self.getRecordIndexStr;
end else if (self.gControlRecordIndex is TLabel) then
begin
(self.gControlRecordIndex as TLabel).Caption:=self.getRecordIndexStr;
end;
end;
except
on E : Exception do
begin end;
end; end; procedure TDataLinkWebber.DataSetScrolled(Distance: Integer);
begin
if giRecno=-1 then begin
giRecno:=1;
end; giRecno:=giRecno Distance;
modifyRecordIndexControl(); end;
procedure TDataLinkWebber.DataSetChanged;
begin
if self.DataSet.eof then begin end;
end; end.
|
webber
初階會員 發表:54 回覆:76 積分:26 註冊:2004-04-20 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |