在DetailBand1BeforePrint事件中用qrrichtext1.Lines.text:=ADOQuery.FieldValues['文章名称'];显示一个字段的值出现了两个问题,请报表 1、第一次调用打印窗口,正常显示。但关闭它,再打开它qrrichtext1是空白,没显示出来。2、退出系统后,系统出现。窗口句柄无效。。,就是说的我那个qrrichtext1。怎么办啊?愁死我了。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 试试看QRRichText1.Text.Assign(ADOQuery.FieldValues['文章名称']); 这应该不是QRREPORT的问题,你再查查别的方向。例如RTF的DLL是否安装正确等。 我没用什么DLL啊。大家真的没有解决方案了吗? 对于第一个问题,我不是在beforeprint中打印的,而是在quickRep的OnNeedData事件中给它赋的值,好像没有你说的问题,而第二个问题好像与qrrichText无关,是不是你程序其他地方内存出错引起的,再检查一下。给你段代码作参考吧unit LaiWenReport;interfaceuses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, QuickRpt, Qrctrls, QRPrntr;type TfrmLaiWenReport = class(TForm) QuickRep1: TQuickRep; QRBand1: TQRBand; QRExpr1: TQRExpr; QRBand2: TQRBand; QRLabel1: TQRLabel; QRLabel3: TQRLabel; QRShape3: TQRShape; QRLabel4: TQRLabel; QRShape5: TQRShape; QRShape8: TQRShape; QRShape9: TQRShape; QRLabel5: TQRLabel; QRLabel6: TQRLabel; QRBand3: TQRBand; QRDBText1: TQRDBText; QRDBText3: TQRDBText; QRShape4: TQRShape; QRDBText4: TQRDBText; QRShape6: TQRShape; QRShape7: TQRShape; QRShape10: TQRShape; QRRichText1: TQRRichText; procedure QuickRep1Preview(Sender: TObject); procedure QuickRep1BeforePrint(Sender: TCustomQuickRep; var PrintReport: Boolean); procedure QuickRep1NeedData(Sender: TObject; var MoreData: Boolean); private { Private declarations } public { Public declarations } end;var frmLaiWenReport: TfrmLaiWenReport;implementationuses datamodual, ViewReport;{$R *.DFM}procedure TfrmLaiWenReport.QuickRep1Preview(Sender: TObject);begin frmViewReport.QRPreview1.QRPrinter := TQRPrinter(Sender);end;procedure TfrmLaiWenReport.QuickRep1BeforePrint(Sender: TCustomQuickRep; var PrintReport: Boolean);begin DMod.qryLWReport.First;end;procedure TfrmLaiWenReport.QuickRep1NeedData(Sender: TObject; var MoreData: Boolean);var i, inteval: Integer;begin MoreData := true; QRRichText1.Lines.Clear; QRRichText1.Lines.Add(DMod.qryLWReport.FieldByName('title').AsString); //以下是动态计算中间分割竖线的长度 i := strlen(PChar(DMod.qryLWReport.FieldByName('title').AsString)); inteval := QRRichText1.Width div QRRichText1.Font.Size; i := (i - i mod inteval) div inteval; QRShape4.Height := (i + 1) * QRBand3.Height; QRShape6.Height := (i + 1) * QRBand3.Height; QRShape7.Height := (i + 1) * QRBand3.Height; QRShape10.Height := (i + 1) * QRBand3.Height; if DMod.qryLWReport.Eof then MoreData := false; DMod.qryLWReport.Next;end;end. 另外你也可以试试这种办法,我朋友以前做过,就是使用TDBMemo链接数据库的某个字段,然后要赋值时先将其赋值给一个TMemo(当然都要设置成自动换行的那种),然后再从TMemo赋值给一个TQRMemo,Memo.Lines.Text := DBMemo.Lines.Text;QRMemo.Lines := Memo.Lines; (前后赋值得方法不一样)你可以参考看看 程序启动后立即运行,执行完成后,自动退出? 求delphi +ado 三层架构例子! 关于一个正则表达式的写法,请大家指点一下 一个简单得不能再简单的问题 在dxdbgrid中如何实现某列弹出可选数据集,并可编辑 如何读取TWebBrowser状态(Status Code) 关于最小化的问题,急急急!!! 动态创建QRLabel2(QRDBText1)怎样放到指定的bands 中啊?? 做资源文件的问题 大虾快来吧!送上100分 怎样发送和接受基于tcp/ip协议的数据包 关于Socket接受数据包的问题?(在线求救)
QRRichText1.Text.Assign(ADOQuery.FieldValues['文章名称']);
大家真的没有解决方案了吗?
unit LaiWenReport;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, QuickRpt, Qrctrls, QRPrntr;type
TfrmLaiWenReport = class(TForm)
QuickRep1: TQuickRep;
QRBand1: TQRBand;
QRExpr1: TQRExpr;
QRBand2: TQRBand;
QRLabel1: TQRLabel;
QRLabel3: TQRLabel;
QRShape3: TQRShape;
QRLabel4: TQRLabel;
QRShape5: TQRShape;
QRShape8: TQRShape;
QRShape9: TQRShape;
QRLabel5: TQRLabel;
QRLabel6: TQRLabel;
QRBand3: TQRBand;
QRDBText1: TQRDBText;
QRDBText3: TQRDBText;
QRShape4: TQRShape;
QRDBText4: TQRDBText;
QRShape6: TQRShape;
QRShape7: TQRShape;
QRShape10: TQRShape;
QRRichText1: TQRRichText;
procedure QuickRep1Preview(Sender: TObject);
procedure QuickRep1BeforePrint(Sender: TCustomQuickRep;
var PrintReport: Boolean);
procedure QuickRep1NeedData(Sender: TObject; var MoreData: Boolean);
private
{ Private declarations }
public
{ Public declarations }
end;var
frmLaiWenReport: TfrmLaiWenReport;implementationuses datamodual, ViewReport;
{$R *.DFM}procedure TfrmLaiWenReport.QuickRep1Preview(Sender: TObject);
begin
frmViewReport.QRPreview1.QRPrinter := TQRPrinter(Sender);
end;procedure TfrmLaiWenReport.QuickRep1BeforePrint(Sender: TCustomQuickRep;
var PrintReport: Boolean);
begin
DMod.qryLWReport.First;
end;procedure TfrmLaiWenReport.QuickRep1NeedData(Sender: TObject;
var MoreData: Boolean);
var
i, inteval: Integer;
begin
MoreData := true;
QRRichText1.Lines.Clear;
QRRichText1.Lines.Add(DMod.qryLWReport.FieldByName('title').AsString);
//以下是动态计算中间分割竖线的长度
i := strlen(PChar(DMod.qryLWReport.FieldByName('title').AsString));
inteval := QRRichText1.Width div QRRichText1.Font.Size;
i := (i - i mod inteval) div inteval;
QRShape4.Height := (i + 1) * QRBand3.Height;
QRShape6.Height := (i + 1) * QRBand3.Height;
QRShape7.Height := (i + 1) * QRBand3.Height;
QRShape10.Height := (i + 1) * QRBand3.Height;
if DMod.qryLWReport.Eof then
MoreData := false;
DMod.qryLWReport.Next;
end;end.
Memo.Lines.Text := DBMemo.Lines.Text;
QRMemo.Lines := Memo.Lines; (前后赋值得方法不一样)
你可以参考看看