FastReport VCL是用于 Delphi、C++ Builder、RAD Studio 和 Lazarus 的报告和文档创建 VCL 库。它提供了可视化模板设计器,可以访问 30 多种格式,并可以部署到云、网站、电子邮件和打印中。
建议将属性编辑器代码放在带有 Editor 后缀的单独文件中。在我们的例子中,有必要为TfrxIBXDatabase.DatabaseName、TfrxIBXTable.IndexName、TfrxIBXTable.TableName属性编写编辑器。请参阅相应章节中有关编写属性编辑器的更多信息。以下是此类文件的示例:
unit frxIBXEditor;
interface
{$I frx.inc}
implementation
uses
Windows, Classes, SysUtils, Forms, Dialogs, frxIBXComponents, frxCustomDB,
frxDsgnIntf, frxRes, IBDatabase, IBTable
{$IFDEF Delphi6}
, Variants
{$ENDIF};
type
TfrxDatabaseNameProperty = class(TfrxStringProperty)
public
function GetAttributes: TfrxPropertyAttributes; override;
function Edit: Boolean; override;
end;
TfrxTableNameProperty = class(TfrxStringProperty)
public
function GetAttributes: TfrxPropertyAttributes; override;
procedure GetValues; override;
end;
TfrxIndexNameProperty = class(TfrxStringProperty)
public
function GetAttributes: TfrxPropertyAttributes; override;
procedure GetValues; override;
end;
{ TfrxDatabaseNameProperty }
function TfrxDatabaseNameProperty.GetAttributes: TfrxPropertyAttributes;
begin
{ this property possesses editor }
Result := [paDialog];
end;
function TfrxDatabaseNameProperty.Edit: Boolean;
var
SaveConnected: Bool;
db: TIBDatabase;
begin
{ get link to TfrxIBXDatabase.Database }
db := TfrxIBXDatabase(Component).Database;
{ create standard OpenDialog }
with TOpenDialog.Create(nil) do
begin
InitialDir := GetCurrentDir;
{ we are interested in *.gdb files }
Filter := frxResources.Get('ftDB') + ' (*.gdb)|*.gdb|' + frxResources.Get('ftAllFiles') + ' (*.*)|*.*';
Result := Execute;
if Result then
begin
SaveConnected := db.Connected;
db.Connected := False;
{ if dialogue is completed successfully, assign new DB name }
db.DatabaseName := FileName;
db.Connected := SaveConnected;
end;
Free;
end;
end;
{ TfrxTableNameProperty }
function TfrxTableNameProperty.GetAttributes: TfrxPropertyAttributes;
begin
{ property represents list of values }
Result := [paMultiSelect, paValueList];
end;
procedure TfrxTableNameProperty.GetValues;
var
t: TIBTable;
begin
inherited;
{ get link to TIBTable component }
t := TfrxIBXTable(Component).Table;
{ fill list of tables available }
if t.Database <> nil then
t.DataBase.GetTableNames(Values, False);
end;
{ TfrxIndexProperty }
function TfrxIndexNameProperty.GetAttributes: TfrxPropertyAttributes;
begin
{ property represents list of values }
Result := [paMultiSelect, paValueList];
end;
procedure TfrxIndexNameProperty.GetValues;
var
i: Integer;
begin
inherited;
try
{ get link to TIBTable component }
with TfrxIBXTable(Component).Table do
if (TableName <> '') and (IndexDefs <> nil) then
begin
{ update indexes }
IndexDefs.Update;
{ fill list of indexes available }
for i := 0 to IndexDefs.Count - 1 do
if IndexDefs[i].Name <> '' then
Values.Add(IndexDefs[i].Name);
end;
except
end;
end;
initialization
frxPropertyEditors.Register(TypeInfo(String), TfrxIBXDataBase, 'DatabaseName', TfrxDataBaseNameProperty);
frxPropertyEditors.Register(TypeInfo(String), TfrxIBXTable, 'TableName', TfrxTableNameProperty);
frxPropertyEditors.Register(TypeInfo(String), TfrxIBXTable, 'IndexName', TfrxIndexNameProperty);
end.
如果您对 FastReport 感兴趣,欢迎加入 FastReport QQ 交流群:702295239
还想要更多吗?您可以点击阅读【FastReport报表2021最新资源盘点】,查找需要的教程资源。上是FastReport .NET慧正在网火热销售中!>>查看价格详情
本站文章除注明转载外,均为本站原创或翻译
欢迎任何形式的转载,但请务必注明出处,尊重他人劳动成果
转载请注明:文章转载自:FastReport控件中文网 [https://www.fastreportcn.com/]
本文地址:https://www.fastreportcn.com/post/3174.html
欢迎任何形式的转载,但请务必注明出处,尊重他人劳动成果
转载请注明:文章转载自:FastReport控件中文网 [https://www.fastreportcn.com/]
本文地址:https://www.fastreportcn.com/post/3174.html
联系电话:023-68661681

返回