procedure TForm1.FormCreate(Sender: TObject);const // you may need to change this path to suit your environment Path = '..\Demos\RichEdit\OverView.RTF'; begin RichEdit1.PlainText := True; RichEdit1.Lines.LoadFromFile(Path); RichEdit2.PlainText := False; RichEdit2.Lines.LoadFromFile(Path); end;
procedure TForm1.BitBtn1Click(Sender: TObject);begin with PrintDialog1 do begin Options := [poPrintToFile]; PrintToFile := True; if Execute then begin if PrintToFile then begin SaveDialog1.Title := 'Print to File: '; if SaveDialog1.Execute then RichEdit1.Lines.SaveToFile(SaveDialog1.FileName); end else RichEdit1.Print(''); end; end;end;
// you may need to change this path to suit your environment
Path = '..\Demos\RichEdit\OverView.RTF';
begin
RichEdit1.PlainText := True;
RichEdit1.Lines.LoadFromFile(Path);
RichEdit2.PlainText := False;
RichEdit2.Lines.LoadFromFile(Path);
end;
with PrintDialog1 do
begin
Options := [poPrintToFile];
PrintToFile := True;
if Execute then
begin
if PrintToFile then
begin
SaveDialog1.Title := 'Print to File: ';
if SaveDialog1.Execute then
RichEdit1.Lines.SaveToFile(SaveDialog1.FileName);
end
else
RichEdit1.Print('');
end; end;end;
我也实现了!
多谢!很奇怪,
不知道早上使用richedit1.lines.loadfromfile的时候会报错。
我是用opendialog选定文件的,
结果读入的时候报错了。
是不是因为我加上了readonly造成的?