rvico TRichView Reference | Overview

Controls, Documents, Items

Top  Previous  Next

There are three main families of classes.

1. VCL controls, descendants of TCustomRichView.

See the diagram of class hierarchy.

The main visual controls are: TRichView, TRichViewEdit, TDBRichView, TDBRichViewEdit.

2. Documents, objects containing items, descendants of TCustomRVFormattedData.

Documents are objects, but not components.

Each RichView or RichViewEdit has such document accessible as RVData property.

They have the most of methods of RichView controls. For example, calling


is equivalent to


Tables have cells. Cells are also documents containing items, cells are descendants of TCustomRVFormattedData.

3. Items of documents, descendants of TCustomRVItemInfo.

Items are objects, but not components.

Items are usually hidden from programmers. They can be added and modified by methods of controls or document objects. The only exception is tables (TRVTableItemInfo).

Documents contain items, some items (tables) can contain documents (cells).


There is an important case: cell editing. When editing cell, RichViewEdit creates a special editor (also TRichViewEdit) on the top of the cell. While editing, all items in the cell are moved in this editor. When editing is finished, items are moved back to the cell.

At any time, object containing cell items is accessible as cell.GetRVData (if cell is not edited, it is the cell itself; if edited, it is RVData of its inplace editor).

Example 1

This example shows that the same procedure can be applied to the main document and table cells.

This example converts all text to upper case

procedure AllUpperCase(RVData: TCustomRVData);

var i,r,c: Integer;

    s: String;

    table: TRVTableItemInfo;


for i := 0 to RVData.ItemCount-1 do

  if RVData.GetItemStyle(i)>=0 then begin // this is a text item

    s := RVData.GetItemText(i); 

    s := AnsiUpperCase(s);



  else if RVData.GetItemStyle(i)=rvsTable then begin

    table := TRVTableItemInfo(RVData.GetItem(i));

    for r := 0 to table.RowCount-1 do

      for c := 0 to table.ColCount-1 do

        if table.Cells[r,c]<>nil then








Example 2

The same task, using different methods

// This procedure will be called for each RichView item 

procedure TForm1.EnumItemsProc(RVData: TCustomRVData;

  ItemNo: Integer;  var UserData1: Integer;

  const UserData2: Stringvar ContinueEnum: Boolean); 

var s: String;


  if RVData.GetItemStyle(ItemNo)>=0 then begin

    s := RVData.GetItemText(i);

    s := AnsiUpperCase(s);



  ContinueEnum := True; 



var v: Integer; 


v := 0;

// RVData.EnumItems calls the specified procedure (EnumItems)

// for each items in RVData and its subdocuments (table cells)

// The second and the third parameters are user defined data,

// they will be passed in the procedure as UserData1 and UserData2

MyRichView.RVData.EnumItems(EnumItemsProc, v, ''); 


The advantage of using RVData.EnumItems is more clear and compact code.

The disadvantage: you cannot use it if you need to add or delete items.

TRichView © trichview.com