WPCubed Product Support

Inserting RTF Text

Hi
I have standard paragraphs stored as RTF text in a database table and would like to insert that into a WPRichText edit component - is that possible

Regards

Bobby

#1 ♥ 0
10.1k Views 4 users read 2 min
support

Sure:

WPRichText1.SelectionAsString := string_with_rtf_text_to_be_inserted;

(Use Field.AsString)

JUlian

#2 ♥ 0

First you need to decide where to insert it, is it going to be at the cursor position or some other pre-allocated spot?

#3 ♥ 0
support

Hi,

That's right. Using CPPosition it is possible to move the cursor position if required.

The Load methods (LoadFromStream) can also be used to insert formatted text.

Julian

#4 ♥ 0

Greetings,

i am using it just like this but the text gets inserted at the end of the paragraph and not where the cursor blinks. (TDBWPRichText V6)

What's the deal?

best wishes,
Wolfgang

#5 ♥ 0
support

Hi,

In a TDPWPRichText you need to make sure the database is in edit mode.

Before You start with your modification call
WPRichText1.Changing

Julian

#6 ♥ 0

I'll try that, thanks Julian.
best wishes, Wolfgang

edit:
sorry, does not work either.

#7 ♥ 0
support

@leprince:
Greetings,

i am using it just like this but the text gets inserted at the end of the paragraph and not where the cursor blinks. (TDBWPRichText V6)

What's the deal?

best wishes,
Wolfgang

I am pretty sure that the problem is a moved cursor when the text is inserted.

Please simplify your text procedure

WP.InputString("xyz") will insert at cursor position.

WP.SelectionAsString := "xyz"; should also insert there - although internally it does something completele different (uses the ANSI reader).

So Your description off the effect is not sufficient to give better advice

#8 ♥ 0

Julian,

of course you are right about too less information; i suspected that you could tell the cause from a few symptoms right away ;-)

I am doing roughly this:

Destination.SelectionAsString := TdxDBGrid(Source).DataSource.DataSet.FieldByName( DataFieldTextbaustein).AsString;

where
Destination is a TDBWPRichText (CPPosition somewhere in the middle)
Source is a TObject
DataFieldTextbaustein is the name of a long varchar field in Sybase SA

The DataFieldTextbaustein contains RTF which was previously edited in a TDBWPRichText. It also contains additional mailmerge fields itself.

IMHO there is a difference whether Destination has focus or not. If i dragdrop something onto it, the insertion works well. If i do it programmatically, it fails.

best wishes,
Wolfgang

#9 ♥ 0
This category is archived. No new posts are possible.