Files
docs-desktop/dotnet-desktop-guide/framework/winforms/controls/set-indents-hanging-indents-bulleted-paragraphs-with-wf-richtextbox.md
T
Andy De George c0ba284473 Initial winforms content migrated (#18)
* Merge winforms framework content to working branch (#14)

* Breadcrumb / TOC / Move net5 to net folder (#15)

* change path from net5 to net

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Add .net 5 winforms placeholder article (#16)

* added some metadata and adjusted net5 placeholder

* corrections

* corrections

* corrections

* Test1

* Swapping landing page vs concept

* fix links

* Fix links

* Fix desc
2020-09-01 16:26:21 -07:00

3.6 KiB

title, ms.date, dev_langs, helpviewer_keywords, ms.assetid
title ms.date dev_langs helpviewer_keywords ms.assetid
Set Indents, Hanging Indents, and Bulleted Paragraphs with RichTextBox Control 03/30/2017
csharp
vb
cpp
text boxes [Windows Forms], setting indents
.rtf files [Windows Forms], formatting in RichTextBox control
examples [Windows Forms], text boxes
RTF files [Windows Forms], formatting in RichTextBox control
RichTextBox control [Windows Forms], setting indents and bullets
text boxes [Windows Forms], bullets
abfb40e6-5642-4691-8ec1-9d9ae91688dc

How to: Set Indents, Hanging Indents, and Bulleted Paragraphs with the Windows Forms RichTextBox Control

The Windows Forms xref:System.Windows.Forms.RichTextBox control has numerous options for formatting the text it displays. You can format selected paragraphs as bulleted lists by setting the xref:System.Windows.Forms.RichTextBox.SelectionBullet%2A property. You can also use the xref:System.Windows.Forms.RichTextBox.SelectionIndent%2A, xref:System.Windows.Forms.RichTextBox.SelectionRightIndent%2A, and xref:System.Windows.Forms.RichTextBox.SelectionHangingIndent%2A properties to set the indentation of paragraphs relative to the left and right edges of the control, and the left edge of other lines of text.

To format a paragraph as a bulleted list

  1. Set the xref:System.Windows.Forms.RichTextBox.SelectionBullet%2A property to true.

    RichTextBox1.SelectionBullet = True  
    
    richTextBox1.SelectionBullet = true;  
    
    richTextBox1->SelectionBullet = true;  
    

To indent a paragraph

  1. Set the xref:System.Windows.Forms.RichTextBox.SelectionIndent%2A property to an integer representing the distance in pixels between the left edge of the control and the left edge of the text.

  2. Set the xref:System.Windows.Forms.RichTextBox.SelectionHangingIndent%2A property to an integer representing the distance in pixels between the left edge of the first line of text in the paragraph and the left edge of subsequent lines in the same paragraph. The value of the xref:System.Windows.Forms.RichTextBox.SelectionHangingIndent%2A property only applies to lines in a paragraph that have wrapped below the first line.

  3. Set the xref:System.Windows.Forms.RichTextBox.SelectionRightIndent%2A property to an integer representing the distance in pixels between the right edge of the control and the right edge of the text.

    RichTextBox1.SelectionIndent = 8  
    RichTextBox1.SelectionHangingIndent = 3  
    RichTextBox1.SelectionRightIndent = 12  
    
    richTextBox1.SelectionIndent = 8;  
    richTextBox1.SelectionHangingIndent = 3;  
    richTextBox1.SelectionRightIndent = 12;  
    
    richTextBox1->SelectionIndent = 8;  
    richTextBox1->SelectionHangingIndent = 3;  
    richTextBox1->SelectionRightIndent = 12;  
    

    Note

    All these properties affect any paragraphs that contain selected text, and also the text that is typed after the current insertion point. For example, when a user selects a word within a paragraph and then adjusts the indentation, the new settings will apply to the entire paragraph that contains that word, and also to any paragraphs subsequently entered after the selected paragraph. For information about selecting text programmatically, see xref:System.Windows.Forms.TextBoxBase.Select%2A.

See also