Share via


Use the RichText Control Sample

File: ...\Samples\Solution\OLE\Rtf.scx

This sample illustrates using a RichText control to display and edit RTF text stored in the memo field of a table.

You can set the ControlSource of a RichText control directly to a character field, but not a memo field. Instead, create a form property to mediate between the RichText control and the memo field.

To store RTF text in a memo field

  1. Set the ControlSource property of the RichText control to the form property.

    THISFORM.oleRTF.ControlSource = THISFORM.cText
    
  2. Store the memo field contents to the form property.

    THISFORM.cText = rtf.source
    
  3. Before moving the record pointer, store the TextRTF property of the RichText control to the memo field.

    REPLACE rtf.Source WITH THISFORM.oleRTF.TextRTF
    

The text stored in the memo file is standard RTF format, for example:

{\rtf1\ansi\deff0\deftab720{\fonttbl{\f0\fswiss MS Sans Serif;}{\f1\froman\fcharset2 Symbol;}{\f2\fswiss Arial;}{\f3\fswiss Arial;}} {\colortbl\red0\green0\blue0;\red255\green0\blue0;} \deflang1033\pard\qc\plain\f3\fs32\i The RichTextBox Control \par \pard\plain\f3\fs20

See Also

Tasks

Solution Samples

Reference

Visual FoxPro Foundation Classes A-Z

Other Resources

ActiveX Solution Samples