Can't load RTF in a table cell programmatically
Posted: Tue Apr 10, 2007 6:09 pm
Hi to everybody,
I've a dummy problem i can't solve.
I need to put RTF text in a table cell programmatically, so i'm trying to obtain the in place editor, for having the InsertRTFFromStreamEd method,
but i'm not able to obtain a GetRVData as TRichViewRVData.
This should-be-simple-code desn't work, probably i've missed something important...
I'm using Delphi 2006 and TRichView 1.9.24.
Thank you very much for any advice.
I've a dummy problem i can't solve.
I need to put RTF text in a table cell programmatically, so i'm trying to obtain the in place editor, for having the InsertRTFFromStreamEd method,
but i'm not able to obtain a GetRVData as TRichViewRVData.
This should-be-simple-code desn't work, probably i've missed something important...
Code: Select all
procedure TForm1.BitBtn3Click(Sender: TObject);
const RTFString='{\rtf1\ansi\ansicpg1252\deff0\deflang1040{\fonttbl{\f0\fswiss\fprq2\fcharset0 Arial;}{\f1\fswiss\fcharset0 Arial;}}{\*\generator Msftedit 5.41.15.1507;}\viewkind4\uc1\pard\ul\b\f0\fs24 RTF Text\ulnone\b0\f1\fs20\par}';
var table: TRVTableItemInfo;
stringStream: TStringStream;
RVData: TCustomRVData;
begin
RichViewEdit1.Clear;
stringStream := TStringStream.Create(RTFString);
try
RichViewEdit1.InsertRTFFromStreamEd(stringStream);
RichViewEdit1.InsertText(#13#13);
table := TRVTableItemInfo.CreateEx(3,3, RichViewEdit1.RVData);
try
table.EditCell(1,1);
RVData:=table.Cells[1,1].GetRVData;
stringStream.WriteString(RTFString);
if RVData is TRVEditRVData then
(TRVEditRVData(RVData).RichView as TCustomRichViewEdit).InsertRTFFromStreamEd(stringStream);
finally
RichViewEdit1.InsertItem('', table)
end;
finally
stringStream.Free;
end;
end;
Thank you very much for any advice.