Modifying RichView Items
|Top Previous Next|
There are several groups of methods for modifying content of RichView:
▪Set***Info methods, introduced in TRichView (viewer-style methods)
▪Set***InfoEd methods of RichViewEdit (editor-style methods)
▪SetCurrent***Info methods of RichViewEdit – the same as Set***InfoEd but work with the "current" (in the caret position) item.
SetCurrent***Info methods are equivalent to Set***InfoEd(CurItemNo,...) But there is one important exception – when using tables, SetCurrent***Info methods modify item in the position of caret regardless its location (in the root editor or in cell inplace editor).
Next, you usually need to get information about the given item.
Finally, you can modify it.
The arguments of these methods are similar to the arguments of Add*** methods.
For the specified items you can use
▪·SetPictureInfo, SetControlInfo return Boolean value: "reformatting is necessary?" (call Invalidate to repaint RichView after it, reformatting is not necessary if new picture or control has the same size).
You can also use:
▪SetItemTag method to change tags of items,
▪SetCheckpointInfo to change checkpoints of items,
▪SetItemExtraIntProperty to change values of additional integer properties,
▪SetItemExtraStrProperty to change values of additional integer properties,
▪SetItemText to change item text (visible text for text items, names for non-text items).
Please read the topic about "tags" if you want to change tags of items.
The limitations of this version are:
▪you can't replace control with the different one;
It is not recommended to use these methods in editor, see Viewer vs Editor
Set***InfoEd methods (editor)
The same set of methods as Set***Info methods, with the same arguments, but they are editor-style methods.
SetCurrent***Info methods (editor)
The same as Set***InfoEd methods, but they work with the current (in position of caret) item.
Additional methods for controls
There are some special methods for resizing inserted controls in editor.
procedure ResizeControl(ItemNo, NewWidth, NewHeight: Integer);
procedure ResizeCurrentControl(NewWidth, NewHeight: Integer);
This is the preferred way to change size of the control. These methods reformat the affected part of document and repaint it.
If your control can sometimes change its size or move itself, you need to call
procedure AdjustControlPlacement(ItemNo: Integer);
procedure AdjustControlPlacement2(Control: TControl);
after such actions. These methods restore the correct position of the control and make all necessary reformatting and repainting if the control was resized.
TRichView © trichview.com