Problems using TppDBRichedit
I have a form which contains a TppDBRichEdit. What I would like to do is as
the report processes I would like to format the text depending on what is
being displayed. For example if the text contains "Hello World" I would
like to color the text red. If the word "boy" is in the text I would like
to color that word blue. I tried doing this in the OnGetRichEditText event
but seem to be having problems. It won't let me assign my text
(ppDBRichedit1.RichText := ppDBPipeline1.fields[0].asstring) like so. then
when I try to scan the Richtext delphi crashes. Am I going about this the
right way? How should I go about putting the field into the control and
then making font and color changes to it?
Thanks in advance,
Rodger
the report processes I would like to format the text depending on what is
being displayed. For example if the text contains "Hello World" I would
like to color the text red. If the word "boy" is in the text I would like
to color that word blue. I tried doing this in the OnGetRichEditText event
but seem to be having problems. It won't let me assign my text
(ppDBRichedit1.RichText := ppDBPipeline1.fields[0].asstring) like so. then
when I try to scan the Richtext delphi crashes. Am I going about this the
right way? How should I go about putting the field into the control and
then making font and color changes to it?
Thanks in advance,
Rodger
This discussion has been closed.
Comments
text using the proper methods and properties. The demo uses a TppRichText
and always assigns it manually from the database. If you want to use the
TppDBRichText component, then there is also a special event to grab the rich
text when it comes across from the database so that you can handle the rich
text manually. See the TppDBRichText.OnGetRichText in the help file for more
information.
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com
Is there an example of the OnGetRichText event? I have been playing with it
and there is something I'm not doing right that causes Delphi to crash.
Thanks in advance,
Rodger
basically does this is the main reports demo #29. The key is to pull the
data from teh dataset directly and then assign the RichText proeprty of the
dbRichText component. Please take a look at demo #29 to see an example of
how to do this in code. The only difference is that it uses the OnPrint
event vs the OnGetRichText event.
Cheers,
Jim Bennett
Digital Metaphors
Declaration
property OnGetRichText: TppGetTextEvent;
Description
The OnGetRichText event fires before the data in the BLOB field is assigned
to RichText property. Use the OnGetRichText event when you want to
manipulate the contents of the BLOB field and assign the resulting RichText
manually. This would allow you to decompress a BLOB field and then assign
the result to RichText. If you create an OnGetRichText event handler, the
DBRichText component will not attempt to assign the BLOB field to the
RichText property at run-time. In order suppress this same behavior at
design-time, set the AutoDisplay property to False.
http://www.digital-metaphors.com
info@digital-metaphors.com
RichEdit1.RichText := ppDBPipeline2.GetFieldForName('DiagLine').AsString;
No text displays in the report and if I try to perform RichText functions on
the RichText property I end up getting exceptions and Delphi crashes. No if
I do it this way in the OnGetRichText event
Text := ppDBPipeline2.GetFieldForName('DiagLine').AsString;
Then the text shows up in the report I get no exceptions but I still can not
format the text using Richtext functions. I am using RB 7.02 and D5
Thanks in advance,
Rodger
instead of using the FindText() method.
Thanks for your help,
Rodger
I seem to be having some weird problems with my TppDBRichText. For one when
I run this code:
rtfStart := ppDBRichText2.FindText(', limit = ', 0, 151, []);
rtfStart comes back 0 unless I am examining ppDBRichText2.RichText at the
time when it does the FindText method. Also when I do this code:
ppDBRichText2.SelStart := rtfStart;
the SelStart stays at 0 and never gets set to rtfStart.
I have rtfStart defined local as a type Integer.
Any ideas?
Thanks in advance,
Rodger
Thanks in advance,
Rodger
The reason you are probably have trouble scanning/editing your RichText is
that you are using a TppDBRichText component. The DBRichText component is
accessed and refreshed from the database numerous times during Report
generation. Try using a TppRichText component instead and loading from the
database using the FieldByName method or the DataPipeline.GetFieldAsString
method as follows:
myRichText.RichText := myTable.FieldByName('myField').AsString;
or
myRichText.RichText := Report.DataPipeline.GetFieldAsString('myField');
Also, you should have no problems using the FindText and SelText when using
the TppRichText component.
--
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
ppDBRichText to ppRichText I got the no data to work, then when I added the
OnPrint event to do the formatting I lost my No Data Available text. I just
can't seem to get both working at the same time.
Thanks for all your help,
Rodger
Try separating the NoData operations with editing the RichText. If you
perhaps edit the RichText before you do any NoData operations you should not
have any problems.
--
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com