trichedit帶格式文本操作
公司係統首頁要添加公告欄,選用trichedit富文本控件,編輯和顯示公告內容。
從trichedit中讀取:
function GetRTF(RE: TRichedit): string;
var
strStream: TStringStream;
begin
strStream := TStringStream.Create('') ;
try
RE.PlainText := False;
RE.Lines.SaveToStream(strStream) ;
Result := strStream.DataString;
finally
strStream.Free
end;
end;
將帶格式內容寫入trichedit:
procedure SetRTF(RE: TRichedit;Datastr :string);
var
strStream: TStringStream;
begin
strStream := TStringStream.Create(Datastr) ;
try
RE.PlainText := False;
RE.Lines.LoadFromStream(strStream);
finally
strStream.Free
end;
end;
調用和效果:
procedure TForm1.Button3Click(Sender: TObject);
var
tmp:string;
begin
tmp := GetRTF(redt1);
//ShowMessage(inttostr(length(tmp)));
//ShowMessage(tmp);
SetRTF(redt2, tmp);
end;
最後更新:2017-05-07 07:57:20