Allows entry and editing of text using advanced formatting features, such as paragraph formatting with left and right indents, hanging indents, bold and italic font and so on. Also supports object embedding using the OLEObjects collection.
RichTextBox does not have the 64K character limit of ordinary TextBox controls, plus it also handles drag and drop from both the clipboard and OLE with mouse button behavior like Microsoft Word. In just a few weekends of work, you too can write your very own word processor using this control in a Manifold script.
This control has a large number of run time properties that do not appear in the Properties dialog. These are listed in this topic together with a summary list of methods to show the great range covered by a "big" control. They should be used based on guidance from a comprehensive text on Visual Basic programming that includes a detailed reference for this control.
Note: Non-Common Control properties are prefaced with "rtf", suppressed in the following for greater legibility.
Properties
In addition to the properties listed below, a Control tab provides access to certain frequently used form properties for this control. See the Form Properties topic for information on those properties.
|
|
RichTextBox |
|
General |
|
|
FileName [load from] |
The filename of the .txt or .rtf file loaded into the rich text box. |
|
OLEDragMode |
DragManual (default) or DragAutomatic. DragManual means the program handles all OLE drag/drop operations, while DragAutomatic means the rich text box handles all OLE drag/drop operations |
|
OLEDropMode |
Set to None (default) if the rich text box does not accept OLE drops and is to display the No Drop cursor if an OLE drop is attempted. Set to Manual, the rich text box will trigger OLE drop events, allowing programs to handle the OLE drop operation in code. |
|
RightMargin |
An integer specifying the indent in twips from the right edge of the text to the right edge of the control. Used for text wrapping, centering and indentation. Default 0 wraps to rightmost part of the control. Take into account border widths if using FixedSingle is set in BorderStyle. |
|
MaxLength |
Long integer specifying the maximum number of characters a user can enter. Default is zero, indicating no maximum. |
|
BulletIndent |
If SetBullet is True, indicates the amount of indent in dialog based units. Will return NULL if the selection spans multiple paragraphs with different margin settings. |
|
AutoVerbMenu |
Determines if a pop-up menu containing a selected object's verbs is displayed when the user right-clicks an OLE object. True - Menu displayed. False - No menu. When True, Click and MouseDown events won't occur when the OLE object is right clicked. |
|
Enabled |
True or False. True means the object can respond to user-generated events, false prevents it from responding. We can disable a control like a rich text box if we wish it to simply display information in a read-only way. |
|
Locked |
True or False. True means the user can scroll and highlight the text in the box but cannot change it. The program can change the text by modifying the rich text box's Text property. False (default) means users can edit the text in the rich text box. |
|
MultiLine |
True or False. True (checked) enables multiple lines of text. A multiple line rich text box will wrap text as the user enters text that extends past the rich text box. If a horizontal scroll bar is present text will not wrap. On a form with no default button, pressing ENTER in a multiple line rich text box will move the focus to the next line. If a default button exists in the form, the user must press CTRL Enter to move to the next line. |
|
HideSelection |
True or False. True means that highlighted text will not appear highlighted when the rich text box loses the focus. False means that highlighted text stays highlighted even when another form or dialog has the focus. |
|
|
|
|
Appearance |
|
|
Appearance |
3D or Flat. 3D is the standard Windows look. Flat results in a rectangular square of background color with a foreground color border. |
|
BorderStyle |
FixedSingle (default) or None. None may be used with Flat Appearance to achieve an uncaptioned rectangle of background color. |
|
MousePointer |
The type of mouse pointer displayed when over the rich text box. Choose from 16 different types plus a custom pointer |
|
ScrollBars |
NoScrollbars, Horizontal, Vertical or Both. Set as desired to cause scroll bars to appear. Scroll bars appear only if MultiLine is set True (checked). Scroll bars will always appear in rich text boxes if enabled by this property even if the text does not extend beyond the borders of the box. |
|
DisableNoScroll |
Determines if scroll bars are disabled. False (Default) - Scroll bars appear normally when displayed. True - scroll bars appear dimmed when displayed and are not enabled. Ignored when ScrollBars property is set to zero, and otherwise scroll bars appear dimmed when lines are too short or lines too few to require scrolling. |
|
|
|
|
Color |
|
|
Back Color |
Color to be used for the rich text box's background. |
|
Color Set |
Choose from Standard Colors (standard Windows non-dithered colors) or Windows System Colors. The latter will be defined by the user's Control Panel settings and is normally the setting used so that the form changes appearance like the rest of Windows if the Control Panel settings are changed. |
|
Color Palette |
Displays available colors. Click on the property to be changed to highlight it in the Properties pane, click on the desired color in the Color Palette pane and then press Apply. |
|
Edit Custom Color |
Change the custom color presented in the Color Palette when the Color Set is set to Windows System Colors. |
|
|
|
|
Font |
|
|
Properties |
Font properties that may be changes. |
|
Font |
Choose a font installed on this system. It's wise to choose standard Windows fonts such as MS Sans Serif that are universally available. |
|
Size |
Size of font, in points. |
|
Effects |
Bold, Italic, Underline or Strikeout. |
|
Sample Text |
A preview of the selected settings. |
|
|
|
|
Picture |
|
|
MouseIcon |
Custom icon to use when the MousePointer property is set to 99. Like Visual Basic, will not load animated cursor (.ani) files. |
Note: The RichTextBox is a data-bound control, so we can bind it with a Data control to a large capacity field in a database system (for example, a TEXT type field in SQL Server or a Binary or Memo field in Access).
Properties
Following is a listing of properties for the RichTextBox control that may be used at run time. We can exploit these properties to create a full-power, professional word processor if so desired.
|
Property |
Description |
|
|
|
|
SelHangingIndent |
Return or set integer margins for the paragraph(s). |
|
SelIndent |
|
|
SelRightIndent |
|
|
SelAlignment |
Controls alignment of paragraph(s). rtfLeft, rtfRight, rtfCenter or Null (current selection spans paragraphs with different alignments). |
|
SelBold |
Return or set font style of currently selected text. False (Default) - None of the characters in the selection or character following the insertion point have the font style. True - All characters have the font style. Null - A mix of font styles. |
|
SelItalic |
|
|
SelStrikethur |
|
|
SelUnderline |
|
|
SelCharOffset |
Integer: Whether character(s) are on the normal text baseline. 0 - character(s) all are on baseline. Null - mix of offsets. > 0 - Superscript above the baseline by given number in twips. < 0 - Subscript below the baseline by given number in twips. |
|
SelColor |
Returns or sets value that determines color of selected text. The value specifies RGB colors in code using RGB or QBColor functions, or System color constants. Null - a mix of colors in selected text. |
|
SelFontName |
Returns or sets font for currently selected text or character(s) immediately following insertion point, using a string that identifies a font installed on the the system. Returns Null if text contains a mix of fonts. |
|
SelFontSize |
Returns or sets font size for currently selected text or character(s) immediately following insertion point, using an integer for font size in points up to 2160. Returns Null if text contains a mix of sizes. Set the SelFontName first, then the size and style. |
|
SelBullet |
Returns or sets value (integer or constant) determining bullet style of paragraph containing current selection or insertion point. False (Default) - paragraph(s) don’t have the bullet style. True - paragraph(s) have bullet style. Null - paragraph(s) have a mix of bullet and non-bullet styles. |
|
SelTabCount |
The number of tab positions in the selected paragraph(s) or in those paragraph(s) following insertion point. |
|
SelTabs(index) |
Returns or sets location for a designated tab, where index is an integer beginning at zero that identifies a specific tab. Location is an integer in dialog units. |
|
SelRTF |
Returns or sets the text string (in .rtf format) in the current selection. Returns zero length string if no text selected. Used with Print function to write .rtf files. |
|
TextRTF |
Returns or sets text in a RichTextBox control, including all .rtf code. Setting this property replaces entire contents with the new string. Used with Print function to write .rtf files. |
|
SelProtected |
Determines if current selection is protected. True - All characters are protected. False - None are protected. Null - A mix of protected/unprotected characters in the selection. Protected text cannot be modified by the user. Used to create forms including areas of fixed text. |
|
OLEObjects |
Returns a reference to the OLEObjects collection. |
|
DataMember |
Returns or sets a specified data member from those offered by the data provider. |
|
DataFormat |
Returns or sets the StdDataFormat object to which a bound object is attached. [Available at design time.] |
|
DataBindings |
Retunrs DataBindings collection object containing the bindable properties available to the programmer. |
|
TabIndex |
Returns or sets the tab order of objects within the Form. |
|
DragIcon |
Returns or sets icon to be used as the pointer in a drag and drop operation. |
|
DragMode |
0 - Set VbManual (default) drag and drop mode. Requires using Drag method to initiate a drag and drop. 1 - Set VbAutomatic mode to automatically initiate a drag and drop. |
|
CausesValidation |
Determines whether Validation event will occur on a second control from which the focus is being shifted. True (Default) - control from which focus shifts causes Validate event. False - control will not cause its Validate event. |
|
TabStop |
Whether the user can use the TAB key to move focus. True (Default) - designates object as a tab stop. False - bypasses the object when user is tabbing. |
|
HelpContextID |
Returns or sets positive integer specifying the context number of the Help topic for this object. 0 (Default) - no context number specified. You will be writing context-sensitive Help for your Manifold script dialogs… right? |
|
Name |
Returns the name used in code to identify this control. |
|
Parent |
Returns the Form that contains this control. |
|
Font |
Returns a Font object. Used to identify a specific Font object whose properties we wish to use. |
|
Container |
Always returns the Form, since there are no other containers available in Manifold script forms. |
|
ToolTipText |
Returns or sets the string to use as a tool tip for this control. Dynamically modified tool tips, anyone? |
|
DataChanged |
Indicates if data in this bound control has been changed by some process other than retrieving data from the current record. False (Default) - data currently in the control, if any, is the same as in the current record. True - it's not. |
|
DataField |
The name of a field to which this data consumer is bound. |
|
DataSource |
The data source through which this data consumer is bound to a database. |
|
WhatsThisHelpID |
An integer for the context number of context-sensitive Help for Windows '95 pop-up help. |
|
SelLength |
The number of characters selected. |
|
SelStart |
An index, the starting point of text selected or the position of the insertion point of no text selected. |
|
SelText |
A string containing the currently selected text or zero length string if no text selected. |
|
Text |
A string containing the text in the RichTextBox. |
|
Index |
A number that uniquely identifies this object. |
|
Tag |
A string that stores any extra data we like about our object. |
|
Visible |
True (Default) - this object is visible. False - this object is hidden. |
|
Object Object.property Object.method |
Returns the object, object's property or object's method. Used to specify an object we want to use in an Automation task. |
Methods
Following is a short summary of methods available with the RichTextBox control.
|
Method |
Description |
|
|
|
|
Find(string, start, end, options) |
Searches the text for a given string using one or more options, as follow. |
|
|
rtfWholeWord |
|
|
rtfMatchCase |
|
|
rtfNoHighlight |
|
|
|
|
GetLineFromChar( charpos) |
Returns number of the line containing a specified long integer character position index number. |
|
|
|
|
LoadFile(pathname, filetype) |
Loads a file using following file types: |
|
|
rtfRTF |
|
|
rtfText |
|
|
|
|
SaveFile(pathname, filetype) |
Saves contents to a file using following file types: |
|
|
rtfRTF |
|
|
rtfText |
|
|
|
|
SelPrint(hdc) |
Sends formatted text to a device for printing using the device context for the target printing device. Example: RichTextBox1.SelPrint(Printer.hDC) |
|
|
|
|
Span(characterset, forward, negate) |
Select text based on specified characterset. |
|
|
|
|
Upto(characterset, forward, negate) |
Moves the insertion point up to but not including the first character that is a member of the specified characterset. |
|
|
|
|
SetFocus |
Moves the focus to the specified form or control. |
|
|
|
|
Drag(action) |
Begins, ends or cancels a drag operation using optional action as follows: |
|
|
vbCancel |
|
|
vbBeginDrag |
|
|
vbEndDrag |
|
|
|
|
Move(left, top, width, height) |
Moves the control. Only the left argument is required. |
|
|
|
|
ZOrder(position) |
Moves the control's position relative to other instances of the same control in z-order. |
|
|
|
|
ShowWhatsThis |
Displays a selected topic in a help file using the What's This Windows '95 popup help. |
|
|
|
|
OLEDrag |
Initiates an OLE drag/drop operation. |
|
|
|
|
Refresh |
Forces a complete repaint of the control. |