共用方式為


RichTextBox.SelectionRightIndent 屬性

定義

RichTextBox 控制項右邊緣和選取文字或加入目前插入點的文字右邊緣之間的距離 (以像素為單位)。

public:
 property int SelectionRightIndent { int get(); void set(int value); };
[System.ComponentModel.Browsable(false)]
public int SelectionRightIndent { get; set; }
[<System.ComponentModel.Browsable(false)>]
member this.SelectionRightIndent : int with get, set
Public Property SelectionRightIndent As Integer

屬性值

目前選取範圍或插入點右邊的縮排空間 (以像素為單位)。

屬性

範例

下列程式碼範例示範如何使用 屬性在 中 RichTextBoxSelectionRightIndent 建立右邊界。 此範例會要求您有包含名為 richTextBox1 的控制項的表單 RichTextBox ,而且範例程式碼是從表單類別內的事件呼叫。

private:
   void WriteIndentedTextToRichTextBox()
   {
      // Clear all text from the RichTextBox;
      richTextBox1->Clear();

      // Specify a 20 pixel right indent in all paragraphs.
      richTextBox1->SelectionRightIndent = 20;

      // Set the font for the text.
      richTextBox1->Font = gcnew System::Drawing::Font( "Lucinda Console",12 );

      // Set the text within the control.
      richTextBox1->SelectedText = "All text is indented 20 pixels from the right edge of the RichTextBox.";
      richTextBox1->SelectedText = "You can use this property with the SelectionIndent property to provide right and left margins.";
      richTextBox1->SelectedText = "After this paragraph the indentation will end.\n\n";

      // Remove all right indentation.
      richTextBox1->SelectionRightIndent = 0;
      richTextBox1->SelectedText = "This paragraph has no right indentation. All text should flow as normal.";
   }
private void WriteIndentedTextToRichTextBox()
{
    // Clear all text from the RichTextBox;
    richTextBox1.Clear();
    // Specify a 20 pixel right indent in all paragraphs.
    richTextBox1.SelectionRightIndent = 20;
    // Set the font for the text.
    richTextBox1.Font = new Font("Lucinda Console", 12);
    // Set the text within the control.
    richTextBox1.SelectedText = "All text is indented 20 pixels from the right edge of the RichTextBox.";
    richTextBox1.SelectedText = "You can use this property with the SelectionIndent property to provide right and left margins.";
    richTextBox1.SelectedText = "After this paragraph the indentation will end.\n\n";
    // Remove all right indentation.
    richTextBox1.SelectionRightIndent = 0;
    richTextBox1.SelectedText = "This paragraph has no right indentation. All text should flow as normal.";
}
Private Sub WriteIndentedTextToRichTextBox()
   ' Clear all text from the RichTextBox;
   RichTextBox1.Clear()
   ' Set the font for the text.
   RichTextBox1.Font = New Font("Lucinda Console", 12)
   ' Specify a 20 pixel right indent in all paragraphs.
   RichTextBox1.SelectionRightIndent = 20
   ' Set the text within the control.
   RichTextBox1.SelectedText = "All text is indented 20 pixels from the right edge of the RichTextBox."
   RichTextBox1.SelectedText = "You can use this property with the SelectionIndent property to provide right and left margins."
   RichTextBox1.SelectedText = "After this paragraph the indentation will end." + ControlChars.CrLf
   ' Remove all right indentation.
   RichTextBox1.SelectionRightIndent = 0
   RichTextBox1.SelectedText = "This paragraph has no right indentation. All text should flow as normal."
End Sub

備註

如果目前未選取任何文字,縮排設定會套用至插入點出現的段落,以及插入點之後輸入控制項的所有文字。 縮排設定會套用到屬性變更為不同的值,或直到插入點移至控制項內的不同段落為止。

如果在控制項內選取文字,則選取的文字和在文字選取範圍之後輸入的任何文字,都會套用此屬性的值。 您可以使用這個屬性來縮排 包含在 檔中的 RichTextBox 段落。 您可以搭配 使用這個屬性來 SelectionIndent 建立段落中顯示的段落。

若要為 控制項中的段落建立擱置縮排,請使用 SelectionHangingIndent 屬性。

適用於