Controls in TRichView Documents

<< Click to display table of contents >>

Controls in TRichView Documents

You can insert any Delphi/C++Builder control in the document.

Style of this item type: rvsComponent (-5)

Methods of TCustomRichView

The following viewer-style methods add item of this type to the end of the document:


The following viewer-style method changes the main properties of item of this type:


The following method returns main properties of the given item of this type:


See also


Methods of TCustomRichViewEdit

The following editor-style method inserts item of this type at the position of caret:


The following editor-style methods modify main properties of the item of this type:



The following method returns main properties of the item of this type at the position of caret:







OnControlAction occurs when the control is loaded from RVF, deleted, moved to/from undo buffer, saved to RVF.


Layout and appearance

This item type has the following integer properties related to layout and appearance:

rvepSpacing – padding (spacing between the control and its border; if a background color is specified, this area is colored);

rvepColor – background color;

rvepBorderWidth, rvepBorderColor – width and color of a border;

rvepOuterHSpacing, rvepOuterVSpacing – horizontal and vertical spacing around the border.

This item type has the following additional additional integer properties related to layout and appearance:

rveipcPercentWidth allows resizing the control according to the document width.

Memory usage

By default, TRichView frees a control when this item is destroyed.

However, if rvepShared integer property is nozero, TRichView does not free it.

Vertical Position

This item type has the following properties affecting vertical position:


extra integer properties: rvepVShift, rvepVShiftAbs.


You can allow resizing this control in editor by assigning non-zero value to its rvepResizable property.

You can forbid mouse resizing of all images and controls in the editor by including rvoNoImageResize in EditorOptions.

Resizing with mouse changes Width and Height properties of the control.

Resizing is activated if this control is selected. You can select this control (for example, in its OnClick event) by calling RichView.SelectControl.

OnItemResize event occurs after resizing.

Other properties

This item type has the following specific integer properties:

rvepVisible allows to hide the control (to set its Visible property to False).

Note about Tags of controls

VCL and LCL: TRichView uses tags of inserted controls (TComponent.Tag) for its own needs. Please do not use and do not modify tags of controls.

(this note is about Tag property of component, not about tags of items; you can use item's tag as you wish).

FireMonkey: TRichView does not use tags of inserted components.

Saving and Loading


In order to load these items from RVF, you need to register a class of the control.

For example:

Delphi: RegisterClass(TButton);

C++Builder: RegisterClass(__classid(TButton));

If rvfoSaveControlsBody is excluded from RVFOptions, control itself is not saved in RVF. When loading such RVF files, OnRVFControlNeeded event occurs.

Export to text, RTF, DocX, and HTML

By default, controls are not exported. Use OnSaveComponentToFile event to save controls.


RichView creates a temporal bitmap, draws the control in it, then prints this bitmap.

It's not possible to create an universal procedure for drawing all possible controls. If you are not satisfied with the results, override the default printing with OnPrintComponent event.

Special Width Mode

Width of controls can be set in percent:

var Item: TRVControlItemInfo


Item := RichView.GetItem(ItemNo) as TRVControlItemInfo;

Item.PercentWidth := 50; // 50% of document width (minus paragraph indents)

The effect will be after reformatting.

See also...