TRichViewXML : SaveToStream ... LoadFromStream
TRichViewXML : SaveToStream ... LoadFromStream
Hi,
I'm trying to copy the data from one RichViewEdit to another using RichViewXML.SaveToStream / .. LoadFromStream.
The destination RVE stays empty . How come ??
procedure TForm1.Button1Click(Sender: TObject);
var
aStream : TStringStream ;
aString : String ;
T: TXMLTree;
MainRoot, DocRoot: TXMLTag;
begin
// SaveToStream
T := TXMLTree.Create(RichViewXML1.Encoding);
try
T.Items.AddTag(RichViewXML1.RootElement, T, T);
MainRoot := T.Items[0];
MainRoot.Items.AddTag('Data', T.Items[0], T);
DocRoot := MainRoot.Items[MainRoot.Items.Count-1];
RichViewXML1.RichView := RichViewEdit1;
RichViewXML1.SaveToXML(DocRoot);
aStream := TStringStream.Create('') ;
T.SaveToStream(aStream,true);
finally
T.Free;
end;
// LoadFromStream
T := TXMLTree.Create(RichViewXML1.Encoding);
try
T.LoadFromStream(aStream);
RichViewXML2.RichView := RichViewEdit2;
MainRoot := T.Items.FindTagOfName(RichViewXML2.RootElement);
if MainRoot<>nil then
begin
DocRoot := MainRoot.Items.FindTagOfName('Data');
if DocRoot<>nil then
begin
RichViewXML2.LoadFromXML(DocRoot);
end;
end;
finally
T.Free;
end;
RichViewEdit2.Format ;
end;
I'm trying to copy the data from one RichViewEdit to another using RichViewXML.SaveToStream / .. LoadFromStream.
The destination RVE stays empty . How come ??
procedure TForm1.Button1Click(Sender: TObject);
var
aStream : TStringStream ;
aString : String ;
T: TXMLTree;
MainRoot, DocRoot: TXMLTag;
begin
// SaveToStream
T := TXMLTree.Create(RichViewXML1.Encoding);
try
T.Items.AddTag(RichViewXML1.RootElement, T, T);
MainRoot := T.Items[0];
MainRoot.Items.AddTag('Data', T.Items[0], T);
DocRoot := MainRoot.Items[MainRoot.Items.Count-1];
RichViewXML1.RichView := RichViewEdit1;
RichViewXML1.SaveToXML(DocRoot);
aStream := TStringStream.Create('') ;
T.SaveToStream(aStream,true);
finally
T.Free;
end;
// LoadFromStream
T := TXMLTree.Create(RichViewXML1.Encoding);
try
T.LoadFromStream(aStream);
RichViewXML2.RichView := RichViewEdit2;
MainRoot := T.Items.FindTagOfName(RichViewXML2.RootElement);
if MainRoot<>nil then
begin
DocRoot := MainRoot.Items.FindTagOfName('Data');
if DocRoot<>nil then
begin
RichViewXML2.LoadFromXML(DocRoot);
end;
end;
finally
T.Free;
end;
RichViewEdit2.Format ;
end;
-
- Site Admin
- Posts: 17555
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Sorry but still not working.
here is the code
here is the code
Code: Select all
procedure TForm1.Button1Click(Sender: TObject);
var
aStream : TStringStream ;
aString : String ;
T: TXMLTree;
MainRoot, DocRoot: TXMLTag;
begin
// SaveToStream
T := TXMLTree.Create(RichViewXML1.Encoding);
try
T.Items.AddTag(RichViewXML1.RootElement, T, T);
MainRoot := T.Items[0];
MainRoot.Items.AddTag('Data', T.Items[0], T);
DocRoot := MainRoot.Items[MainRoot.Items.Count-1];
RichViewXML1.RichView := RichViewEdit1;
RichViewXML1.SaveToXML(DocRoot);
aStream := TStringStream.Create('') ;
T.SaveToStream(aStream,true);
finally
T.Free;
end;
// LoadFromStream
aStream.Position := 0 ;
RichViewXML2.InsertFromStream(aStream);
T := TXMLTree.Create(RichViewXML1.Encoding);
try
T.LoadFromStream(aStream);
RichViewXML2.RichView := RichViewEdit2;
MainRoot := T.Items.FindTagOfName(RichViewXML2.RootElement);
if MainRoot<>nil then
begin
DocRoot := MainRoot.Items.FindTagOfName('Data');
if DocRoot<>nil then
begin
RichViewXML2.InsertFromStream(aStream);
end;
end;
finally
T.Free;
end;
RichViewEdit2.Format ;
end;
InsertFromStreamEd
Hi!
I have the same problem. The destenation is empty.
Code:
Source.SaveRTFToStream(Stream, False);
Stream.Position := 0;
stream.SaveToFile('C:\streamtest.txt');
Stream.Position := 0;
Dest.InsertRTFFromStreamEd(Stream);
Dest.Format;
I have the same problem. The destenation is empty.
Code:
Source.SaveRTFToStream(Stream, False);
Stream.Position := 0;
stream.SaveToFile('C:\streamtest.txt');
Stream.Position := 0;
Dest.InsertRTFFromStreamEd(Stream);
Dest.Format;
-
- Site Admin
- Posts: 17555
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Her is the code. I have made a DBRichView and the purpose is to copy from one to the other with the help of stream. I see that the stream has data butt the destination is empty. it is the line
that is the problem. Dest is empty.
Can you pleas help?
[/code]
Code: Select all
Dest.InsertRTFFromStreamEd(Stream);
Can you pleas help?
Code: Select all
procedure TForm1.cxButton2Click(Sender: TObject);
var
ItemNo,
Offset: Integer;
Stream: TMemoryStream;
Source,
Dest: TDBRichViewEdit;
frm: TForm;
sStyle: TRVStyle;
begin
try
Stream := TMemoryStream.Create;
frm := TForm.Create(nil);
sStyle := TRVStyle.Create(frm);
Dest := TDBRichViewEdit.Create(frm);
Dest.Parent := frm;
Dest.Style := sStyle;
Dest.DataField := 'INFODATA';
Dest.Datasource := dsTo;
Source := TDBrichViewEdit.Create(frm);
Source.Parent := frm;
Source.Style := sStyle;
Source.DataField := 'INFODATA';
Source.Datasource := dsFrom;
if (dsTo.DataSet.Bof and dsTo.DataSet.Eof) then
begin
dsTo.DataSet.Insert;
end else
begin
dsTo.DataSet.Edit;
end;
ItemNo := Dest.ItemCount -1;
Offset := Dest.GetOffsAfterItem(ItemNo);
Dest.SetSelectionBounds(ItemNo, Offset, ItemNo, Offset);
Source.SaveRTFToStream(Stream, False);
Stream.Position := 0;
Dest.InsertRTFFromStreamEd(Stream);
Dest.Format;
finally
FreeAndNil(Dest);
FreeAndNil(Source);
FreeAndNil(sStyle);
FreeAndNil(frm);
FreeAndNil(Stream);
cxPageControl1.ActivePage := DBRichView_Dest;
end;
end;
-
- Site Admin
- Posts: 17555
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Site Admin
- Posts: 17555
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Site Admin
- Posts: 17555
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Site Admin
- Posts: 17555
- Joined: Sat Aug 27, 2005 10:28 am
- Contact: