翻譯|使用教程|編輯:楊鵬連|2021-07-19 09:35:47.327|閱讀 267 次
概述:TfrxIBXTable繼承自TfrxCustomDataSet標準類。所有基本功能(操作字段列表、主從、基本屬性)都已經在基本類中實現。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
FastReport VCL是用于 Delphi、C++ Builder、RAD Studio 和 Lazarus 的報告和文檔創建 VCL 庫。它提供了可視化模板設計器,可以訪問 30 多種格式,并可以部署到云、網站、電子郵件和打印中。
下一個組件是TfrxIBXTable. 它繼承自TfrxCustomDataSet標準類。所有基本功能(操作字段列表、主從、基本屬性)都已經在基本類中實現。我們只需要定義特定于給定組件的屬性。
TfrxIBXTable = class(TfrxCustomTable)
private
FDatabase: TfrxIBXDatabase;
FTable: TIBTable;
procedure SetDatabase(const Value: TfrxIBXDatabase);
protected
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
procedure SetMaster(const Value: TDataSource); override;
procedure SetMasterFields(const Value: String); override;
procedure SetIndexFieldNames(const Value: String); override;
procedure SetIndexName(const Value: String); override;
procedure SetTableName(const Value: String); override;
function GetIndexFieldNames: String; override;
function GetIndexName: String; override;
function GetTableName: String; override;
public
constructor Create(AOwner: TComponent); override;
constructor DesignCreate(AOwner: TComponent; Flags: Word); override;
class function GetDescription: String; override;
procedure BeforeStartReport; override;
property Table: TIBTable read FTable;
published
property Database: TfrxIBXDatabase read FDatabase write SetDatabase;
end;
constructor TfrxIBXTable.Create(AOwner: TComponent);
begin
{ create component – table }
FTable := TIBTable.Create(nil);
{ assign link to DataSet property from basic class – do not forget this string! }
DataSet := FTable;
{ assign link to connection to DB by default }
SetDatabase(nil);
{ after that basic constructor may be called in}
inherited;
end;
{ this constructor is called at moment of adding components to report. It connects table to TfrxIBXDatabase component automatically, if it is already present. }
constructor TfrxIBXTable.DesignCreate(AOwner: TComponent; Flags: Word);
var
i: Integer;
l: TList;
begin
inherited;
l := Report.AllObjects;
for i := 0 to l.Count - 1 do
if TObject(l[i]) is TfrxIBXDatabase then
begin
SetDatabase(TfrxIBXDatabase(l[i]));
break;
end;
end;
class function TfrxIBXTable.GetDescription: String;
begin
Result := 'IBX Table';
end;
{ trace TfrxIBXDatabase component deleting. We address this component in FDatabase property. Otherwise we can get error. }
procedure TfrxIBXTable.Notification(AComponent: TComponent; Operation: TOperation);
begin
inherited;
if (Operation = opRemove) and (AComponent = FDatabase) then
SetDatabase(nil);
end;
procedure TfrxIBXTable.SetDatabase(const Value: TfrxIBXDatabase);
begin
{ Database property of TfrxIBXDatabase type, and not of TIBDatabase one! }
FDatabase := Value;
{ if value <> nil, connect table to selected component }
if Value <> nil then
FTable.Database := Value.Database
{ otherwise, try to connect to DB by default, defined in TfrxIBXComponents component }
else if IBXComponents <> nil then
FTable.Database := IBXComponents.DefaultDatabase
{ if there were no TfrxIBXComponents for some reason, reset to nil }
else
FTable.Database := nil;
{ if connection was a success DBConnected flag should be put }
DBConnected := FTable.Database <> nil;
end;
function TfrxIBXTable.GetIndexFieldNames: String;
begin
Result := FTable.IndexFieldNames;
end;
function TfrxIBXTable.GetIndexName: String;
begin
Result := FTable.IndexName;
end;
function TfrxIBXTable.GetTableName: String;
begin
Result := FTable.TableName;
end;
procedure TfrxIBXTable.SetIndexFieldNames(const Value: String);
begin
FTable.IndexFieldNames := Value;
end;
procedure TfrxIBXTable.SetIndexName(const Value: String);
begin
FTable.IndexName := Value;
end;
procedure TfrxIBXTable.SetTableName(const Value: String);
begin
FTable.TableName := Value;
end;
procedure TfrxIBXTable.SetMaster(const Value: TDataSource);
begin
FTable.MasterSource := Value;
end;
procedure TfrxIBXTable.SetMasterFields(const Value: String);
begin
FTable.MasterFields := Value;
FTable.IndexFieldNames := Value;
end;
{ we need to implement this method in some cases }
procedure TfrxIBXTable.BeforeStartReport;
begin
SetDatabase(FDatabase);
end;
如果您對 FastReport 感興趣,歡迎加入 FastReport QQ 交流群:702295239
還想要更多嗎?您可以點擊閱讀【FastReport報表2021最新資源盤點】,查找需要的教程資源。上是FastReport .NET慧正在網火熱銷售中!>>查看價格詳情
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉載自: