Page 1 of 1
Select a range in RVData!
Posted: Thu Nov 23, 2006 5:15 pm
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
Posted: Fri Nov 24, 2006 8:59 pm
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.
Posted: Fri Nov 24, 2006 9:09 pm
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
Posted: Sat Nov 25, 2006 12:40 pm
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
Posted: Sat Nov 25, 2006 3:41 pm
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.
Posted: Sat Nov 25, 2006 4:29 pm
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.