Select a range in RVData!

General TRichView support forum. Please post your questions here
Post Reply
mamouri
Posts: 63
Joined: Sat Aug 19, 2006 5:06 am

Select a range in RVData!

Post by mamouri »

Hi,

There are RVGetSelection and RVSetSelection in RVLinear for selecting a range in RichView by SelStart and SelLength like TRichEdit.

These two functions both require a TCustomRichView (Edited: TCustomRichViewEdit -> TCustomRichView). Is there another method for selecting a range in TRVData?


Thank you
Last edited by mamouri on Fri Nov 24, 2006 9:05 pm, edited 1 time in total.
Sergey Tkachenko
Site Admin
Posts: 17310
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

These procedures works with a TCustomRichView, it's not necessary a TCustomRichViewEdit.

These procedures work with selection in table cells as well.
mamouri
Posts: 63
Joined: Sat Aug 19, 2006 5:06 am

Post by mamouri »

Sorry. I was mistyped. I mean TCustomRichView not TCustomRichViewEdit.

In fact I want select part of cell of a table not a whole TCustomRichView. RVGetSelection and RVSetSelection both work with TCustomRichView and not TCustomRVData or TFormattedRVData or TRVCellData.

It's possible to save content of the cell into a stream, copy it into new built-in trichviewedit and select any part required, change the style and save it again into stream and load stream into the cell. But I want to know is there faster method for doing so? I mean is there a function to select part of document in TRVData or TRVEData (RVData for RichViewEdit)?

I hope I was clear
Thank you
Sergey Tkachenko
Site Admin
Posts: 17310
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Once again, RVGetSelection and RVSetSelection work for all TCustomRVDatas inside the given TCustomRichViewEdit, so special functions for TCustomRVData are not necessary.

For example, you can select some items in cell of table, then call RVGetSelection for RichView containing this table, and the selection will be stored. When you call RVSetSelection, this selection will be restored.
For these functions, it's not important if the selection is in the main document or in table cell.

But if you want to apply new text style to the selection, you really need to do it in TRichViewEdit, because TRichView and cells do not have methods for applying text style.
It's simple to change the style of some specific text items in TRichView or cell, but it's not simple to change style of part of text item, it requires using many undocumented methods, for example see here: http://www.trichview.com/forums/viewtopic.php?t=57
mamouri
Posts: 63
Joined: Sat Aug 19, 2006 5:06 am

Post by mamouri »

Actually I don't get position of selected part using RVGetSelection function. I have a database that store start position and length of a part in text that must change it's style. So here is what I'm doing:

Code: Select all

while not tblStory.Eof do begin
  Add New Row to RichViewEdit
  Add Text of story to the NEW ADDED ROW
  while not tblFormats.Eof do begin
    Read SelStart and SelLength
    Select it in the NEW ADDED ROW
    change it's style
  end;
end;
I think this is not very easy in trichview. if it's not possible to accomplish this I can copy the content into temp trichviewedit and do all required Formatting and then copy temp richviewedit content into the new added row.
Sergey Tkachenko
Site Admin
Posts: 17310
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

I think the simplest solution would be loading text in hidden TRichViewEdit, apply text style and then add the result to the main TRichView.
Post Reply