Link to home
Start Free TrialLog in
Avatar of npuleio
npuleio

asked on

TRichEdit and TFrame

Hello everyone!

I'm using C++ Builder 6.0 and I have a TFrame with inside a TPageControl where in  a page I have a TRichEdit.
The fact is: I load some text from a database field into TRichEdit's text (and with debug I see I have text) but when I show the richedit I see like empty richedit.
Indeed I have a TRichEdit in another simple form and I can see the text... As you know it is maybe a bad issue between TRichEdit being in a TFrame instead of a TForm?...
Is there maybe a way to solve it, for example with API calls?...

Thanks a lot to everyone!
Ciao,
Luigi
edtDocumentation->Text = ADOQuery_Qry->Fields->Fields[2]->AsString;

Open in new window

Avatar of George Tokas
George Tokas
Flag of Greece image

Ciao Luigi,
To add strings in a TrichEdit its the same as TMemo:
TRichEdit->Lines->Add(TheAnsiString);
or TStrings:
TRichEdit->Lines = TStringList;
so if edtDocumentation = TRichEdit
then:
edtDocumentation->Lines->Add(ADOQuery_Qry->Fields->Fields[2]->AsString);

George Tokas.
Avatar of npuleio
npuleio

ASKER

Hello George....

if I do that I get an exception "RichEdit line insertion error" doing the ->Add(...->AsString); thing and the text is just fine since when I inserted the text into database I did a paste from a Word document...

Same thing happens if I do:

TStringList* stringdocument = new TStringList();
stringdocument->Add(ADOQuery_Qry->Fields->Fields[2]->AsString);
edtDocumentation->Lines->AddStrings(stringdocument);

ciao,
Luigi
Avatar of npuleio

ASKER

Hello again,

I have also a TWinControl component where I created a format-text toolbar and a RichEdit, where specifically for the RichEdit I passed to the ancestor something like this:

#define RICHEDIT30 "Riched20.dll"

if (!_RichEditModule)
  _RichEditModule = ::LoadLibrary(RICHEDIT30);

if (_RichEditModule != 0) {
  Ancestor::CreateParams();
  CreateSubClass(Params, RICHEDIT_CLASSA);
  ...
  ...
}

So I would manage also TStrings Lines... how I could get and pass Lines between the handle creating a property Lines?...

Thanks
Ciao, Luigi
Avatar of npuleio

ASKER

Actually, to avoid that exception "RichEdit line insertion error", I put an ugly try { .... } catch(Exception &e) { } at least it works...

Ciao, Luigi
Avatar of npuleio

ASKER

Couldn't get a good answer actually... and it works quite OK with a try { } catch(Exception &e) { } so I solved it with that.
For a moderator, can be this question closed?..Thanks
Ooops...
Sorry...
Forgot to answer...
I'll be back to you in a few hours....

George Tokas.
Hello again Luigi,
I tried having a RichEdit control in a frame and I added lines and from a control (TButton) outside the frame and works ok...
Try the following:
AnsiString S;
S = ADOQuery_Qry->Fields->Fields[2]->AsString;
RichEdit->Lines->Add(S);
Is that failing also??

George.
Avatar of npuleio

ASKER

I tried that too but it failed too... I tried also something like this:

TStringList* ts = new TStringList(ADOQuery_Qry->Fields->Fields[2]->AsString);
RichEdit->Lines->Add(ts);

since Lines is a TStrings, but it failed that too...
ASKER CERTIFIED SOLUTION
Avatar of npuleio
npuleio

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial