JavaScript Editor JavaScript Editor     JavaScript Debugger

Previous Section Next Section

Main Page

Indenting Text in Rich Text Boxes

One of the aspects of word processors that users have gotten used to is the ability to indent text, and rich text boxes (which are designed to be RTF word processors in a control) have this capability.

To indent paragraph by paragraph, you use these properties (you set them to numeric values to indicate the indentation amount, using pixels):

  • SelectionIndent— Indents first line of the paragraph

  • SelectionHangingIndent— Indents all other lines of the paragraph with respect to SelectionIndent

  • SelectionRightIndent— Sets the right indentation of the paragraph

To see this at work, take a look at the RichTextBoxes example on the CD-ROM and click the Indent text button as in Figure 5.9, which indents the text in the top rich text box this way (keep in mind all measurements are in pixels):

Private Sub Button3_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles Button3.Click
    RichTextBox1.SelectionIndent = 20
    RichTextBox1.SelectionHangingIndent = - 25
    RichTextBox1.SelectionRightIndent = 10
End Sub

Figure 5.9: Indenting a paragraph of text.

Besides working paragraph by paragraph, you can set the right margin for the whole rich text at once with the RightMargin property. Just assign this property the new value you want for the right margin and you're set.

Previous Section Next Section

JavaScript Editor Free JavaScript Editor     JavaScript Editor