Transfer contents of rich text field to another?
Posted: Tue Feb 14, 2012 6:39 am
Hello all,
I am absolutely new to TRichView and just looking for a solution for this (Windows 7, Delphi 2010):
In a form (Form1) a record from a database is edited. It includes a rich text that is shown in in a TDBRichViewEdit field. Everything works fine.
Because there are many other fields on that form the rich text field cannot be high enough to show a lot of information (heavy scrolling). So it would be nice to open a second form (Form2) that has only a unbound rich text field of type TRichViewEdit (like a simple text editor that can be maximized to fit the whole screen), edit the text and on closing Form2 rewrite the text to the field on Form1.
I tried things like this:
rtSS : TStream is a global variable
// Test 1 ====================================:
//On click on a button in Form1 to open the text editor:
rtSS := TStream.Create;
rtSS := TStringStream.Create('', TEncoding.UTF8); // für Unicode
STATUS.rtSS.Position := 0;
Self.RichTextEdit1.SaveTextToStreamW('', rtSS, 80, false, false); // what to do here with the 80 ???
...open Form2...
...and on creating Form2:
Self.RichTextEdit1.Clear;
Self.RichTextEdit1.LoadTextFromStreamW(rtSS, 0, 0, True);
Self.RichTextEdit1.Format;
Self.RichTextEdit1.EndUpdate;
// Test 2 ====================================:
//On click on a button in Form1 to open the text editor:
rtSS := TStream.Create;
Self.RichTextEdit1.SaveRVFToStream(rtSS, false);
...open Form2...
...and on creating Form2:
Self.RichTextEdit1.BeginUpdate;
Self.RichTextEdit1.Clear;
Self.RichTextEdit1.LoadRVFFromStream(rtSS);
Self.RichTextEdit1.Format;
Self.RichTextEdit1.EndUpdate;
In either case Form2 is opened, but the rich text field is completely empty. So, how can the contents of one rich text field be taken to another (in another form)? If this is a stupid question, please be patient with me, but I am just beginning to work with TRichView.
Thank you in advance.
Joe
I am absolutely new to TRichView and just looking for a solution for this (Windows 7, Delphi 2010):
In a form (Form1) a record from a database is edited. It includes a rich text that is shown in in a TDBRichViewEdit field. Everything works fine.
Because there are many other fields on that form the rich text field cannot be high enough to show a lot of information (heavy scrolling). So it would be nice to open a second form (Form2) that has only a unbound rich text field of type TRichViewEdit (like a simple text editor that can be maximized to fit the whole screen), edit the text and on closing Form2 rewrite the text to the field on Form1.
I tried things like this:
rtSS : TStream is a global variable
// Test 1 ====================================:
//On click on a button in Form1 to open the text editor:
rtSS := TStream.Create;
rtSS := TStringStream.Create('', TEncoding.UTF8); // für Unicode
STATUS.rtSS.Position := 0;
Self.RichTextEdit1.SaveTextToStreamW('', rtSS, 80, false, false); // what to do here with the 80 ???
...open Form2...
...and on creating Form2:
Self.RichTextEdit1.Clear;
Self.RichTextEdit1.LoadTextFromStreamW(rtSS, 0, 0, True);
Self.RichTextEdit1.Format;
Self.RichTextEdit1.EndUpdate;
// Test 2 ====================================:
//On click on a button in Form1 to open the text editor:
rtSS := TStream.Create;
Self.RichTextEdit1.SaveRVFToStream(rtSS, false);
...open Form2...
...and on creating Form2:
Self.RichTextEdit1.BeginUpdate;
Self.RichTextEdit1.Clear;
Self.RichTextEdit1.LoadRVFFromStream(rtSS);
Self.RichTextEdit1.Format;
Self.RichTextEdit1.EndUpdate;
In either case Form2 is opened, but the rich text field is completely empty. So, how can the contents of one rich text field be taken to another (in another form)? If this is a stupid question, please be patient with me, but I am just beginning to work with TRichView.
Thank you in advance.
Joe