Inserttext into rich text

General TRichView support forum. Please post your questions here
Post Reply
lorenaustin
Posts: 1
Joined: Wed Mar 11, 2020 5:29 pm

Inserttext into rich text

Post by lorenaustin »

I want to insert items from a dbgrid into the text, I will use drag and drop, so far so good, I know how to do. The problem is that when using a data from a dbgrid I need to change the color of the line and in case the user deletes the dragged text, dbgrid needs to return the line to normal.
I thought of leaving a comment within the text dragged in rich text using {\ * \ annotdef ...} - it would contain a reference to the database field that I would read to update the gride and - if the user deletes the inserted text, the comment would be erased together - also allowing you to update the gride, but to make it right I would have to drag the text into the code at the rich text level, and I only saw the inserttext method that I do not think inserts at that text level.
Sergey Tkachenko
Site Admin
Posts: 17267
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Inserttext into rich text

Post by Sergey Tkachenko »

If you want to insert RTF/RVF, you can create TMemoryStream, write RTF/RVF there, and use InsertRTFFromStream/InsertRVFFromStream.
However, annotations are not supported, but if you will use RVF format, alternative solutions are possible.
Is dragged text multiline, does it need to be edited? What if the user copy-pastes a dragged text (and creates multiple instances of it)?
Post Reply