为上fastreport里的控件里面的例子,请问各位如何控制列的宽度?急用.在线等========= ( 积分: 5 )

  • 主题发起人 主题发起人 nantwww
  • 开始时间 开始时间
N

nantwww

Unregistered / Unconfirmed
GUEST, unregistred user!
为上fastreport里的控件里面的例子,请问各位如何控制列的宽度?
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
frxClass, StdCtrls, frxCross, Db, DBTables, Grids, DBGrids, ADODB;

type
TForm1 = class(TForm)
Button1: TButton;
frxCrossObject1: TfrxCrossObject;
Table1: TTable;
AC1: TADOConnection;
AQ1: TADOQuery;
DBGrid1: TDBGrid;
DataSource1: TDataSource;
frxReport1: TfrxReport;
procedure Button1Click(Sender: TObject);
procedure frxReport1BeforePrint(c: TfrxReportComponent);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
begin
frxReport1.ShowReport;
end;

procedure TForm1.frxReport1BeforePrint(c: TfrxReportComponent);
var
Cross: TfrxCrossView;
i, j: Integer;
begin
if c is TfrxCrossView then
begin
Cross := TfrxCrossView(c);

AQ1.First;
i := 0;
while not AQ1.Eof do
begin
for j := 0 to AQ1.Fields.Count - 1 do
Cross.AddValue(, [AQ1.Fields[j].DisplayLabel], [AQ1.Fields[j].AsString]);

AQ1.Next;
Inc(i);
end;
end;
end;

end.
 
为上fastreport里的控件里面的例子,请问各位如何控制列的宽度?
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
frxClass, StdCtrls, frxCross, Db, DBTables, Grids, DBGrids, ADODB;

type
TForm1 = class(TForm)
Button1: TButton;
frxCrossObject1: TfrxCrossObject;
Table1: TTable;
AC1: TADOConnection;
AQ1: TADOQuery;
DBGrid1: TDBGrid;
DataSource1: TDataSource;
frxReport1: TfrxReport;
procedure Button1Click(Sender: TObject);
procedure frxReport1BeforePrint(c: TfrxReportComponent);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
begin
frxReport1.ShowReport;
end;

procedure TForm1.frxReport1BeforePrint(c: TfrxReportComponent);
var
Cross: TfrxCrossView;
i, j: Integer;
begin
if c is TfrxCrossView then
begin
Cross := TfrxCrossView(c);

AQ1.First;
i := 0;
while not AQ1.Eof do
begin
for j := 0 to AQ1.Fields.Count - 1 do
Cross.AddValue(, [AQ1.Fields[j].DisplayLabel], [AQ1.Fields[j].AsString]);

AQ1.Next;
Inc(i);
end;
end;
end;

end.
 
private
{ Private declarations }
FWidth: Integer;
public
{ Public declarations }
end;
....
...

procedure TForm1.frReport1EnterRect(Memo: TStringList; View: TfrView);
begin
View.dx := FWidth;
end;

procedure TForm1.frReport1PrintColumn(ColNo: Integer; var Width: Integer);
var
Field: TField;
begin
Field := Table1.Fields[ColNo - 1];
if Field is TStringField then
Width := Field.Size * Canvas.TextWidth('W')
else if Field is TDateTimeField then
Width := 15 * Canvas.TextWidth('W')
else
Width := 64;
FWidth := Width;
end;
 
多人接受答案了。
 
后退
顶部