I am using the AdvRichEditor in a form it saves the richtext to a varchar field ( AdvRichEditor1.SaveToStream(ss);) in the database and the save is sucessfull however when I try to retrieve the text an display it in the AdvRichEditor (AdvRichEditor1.LoadFromStream(ss);) I get an error sayin it cannot load the stram
var
RichContent: String;
ss : TStringStream;
s1: String;
ss1 : TStringStream;
begin
inherited;
RichContent:= tbltesttable.GetValue('test_field');
ss := TStringStream.Create(RichContent);
try
AdvRichEditor1.LoadFromStream(ss); //code errors here
SaveToStream() writes as a binary stream. This will be problematic in a varchar field. If you want to use SaveToStream(), LoadFromStream(), please use a binary blob field.
is there a way to save and retrieve rich text to a Varchar field
used jvrichEdit(delphi-jedi) and it works fine with varchar fields
jvrichedit1.Lines..SaveToStream(ss);
tbltesttabele.setvalue('test_field',copy(ss.DataString,1,length(ss.DataString) -1));
var
s: String;
ss : TStringStream;
s1: String;
ss1 : TStringStream;
begin
inherited;
s:= tbltesttable.GetValue('test_field');
s1:= tblHelpModule.GetValue(''test_field');
jvrichedit1.PlainText := false;
jvrichedit2.PlainText := false;
ss := TStringStream.Create(s);
ss1 := TStringStream.Create(s1);
try
jvrichedit1.Lines.LoadFromStream(ss);
// jvrichedit2.Lines.LoadFromStream(ss1);
finally
ss.Free;
ss1.Free;
end;
Via RTF via the TAdvRichEditorRTFIO component
Hi Bruno
I still cannot load the field this is my code (It does not give me an error now) TAdvRichEditorRTFIO is connected to the AdvRichEditor1.
AdvRichEditor1.SaveToStream(ss);
tbltest.setvalue('test_field',copy(ss.DataString,1,length(ss.DataString) -1));
// load
var
RichContent: String;
ss :TStringStream;
s1: String;
ss1 : TStringStream;
begin
inherited;
RichContent:= tbltest.GetValue('test_field');
ss := TStringStream.Create(RichContent);
try
AdvRichEditorRTFIO1.Load(ss);
finally
ss.Free;
If you are going to use RTF, you need to do BOTH the read & write in RTF.
Thanks It worked. Is there a property that I need to turn off or on (AdvRichEdit) to have the ability to go to the next line (Line break ) when the "enter" key is pressed. When I press enter it goes to select font type.
I'm not sure I understand. Pressing enter inserts a linebreak always. Do you see something different? If so, how exactly can this be reproduced?
The cursor is on testing and when I hit the enter key it highlights the font selection rather than inserting a line break
I dropped a TAdvRichEditorFormatButtonBar and TAdvRichEditor on the form but I could not reproduce such behavior.
What do you do different from this?
If a problem persists, please isolate this and send a sample source project with which we can reproduce this here.