RichTextBox.SelectionIndent 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定選取開始行的縮排長度(以像素為單位)。
public:
property int SelectionIndent { int get(); void set(int value); };
[System.ComponentModel.Browsable(false)]
public int SelectionIndent { get; set; }
[<System.ComponentModel.Browsable(false)>]
member this.SelectionIndent : int with get, set
Public Property SelectionIndent As Integer
屬性值
目前插入點左側縮排的距離(以像素計)。
- 屬性
範例
以下程式碼範例示範如何使用 屬性SelectionIndent來指定縮排文字RichTextBox。 此範例要求 RichTextBox 表單中加入一個名為 richTextBox1的控制項。
private:
void WriteIndentedTextToRichTextBox()
{
// Clear all text from the RichTextBox;
richTextBox1->Clear();
// Specify a 20 pixel indent in all paragraphs.
richTextBox1->SelectionIndent = 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 left edge of the RichTextBox.";
richTextBox1->SelectedText = "You can use this property to provide proper indentation such as when writing a letter.";
richTextBox1->SelectedText = "After this paragraph the indent is returned to normal spacing.\n\n";
richTextBox1->SelectionIndent = 0;
richTextBox1->SelectedText = "No indenation is applied to this paragraph. All text in the paragraph flows from each control edge.";
}
private void WriteIndentedTextToRichTextBox()
{
// Clear all text from the RichTextBox;
richTextBox1.Clear();
// Specify a 20 pixel indent in all paragraphs.
richTextBox1.SelectionIndent = 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 left edge of the RichTextBox.";
richTextBox1.SelectedText = "You can use this property to provide proper indentation such as when writing a letter.";
richTextBox1.SelectedText = "After this paragraph the indent is returned to normal spacing.\n\n";
richTextBox1.SelectionIndent = 0;
richTextBox1.SelectedText = "No indenation is applied to this paragraph. All text in the paragraph flows from each control edge.";
}
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 indent in all paragraphs.
RichTextBox1.SelectionIndent = 20
' Set the text within the control.
RichTextBox1.SelectedText = "All text is indented 20 pixels from the left edge of the RichTextBox."
RichTextBox1.SelectedText = "You can use this property to provide proper indentation such as when writing a letter."
RichTextBox1.SelectedText = "After this paragraph the indent is returned to normal spacing." + ControlChars.Crlf
RichTextBox1.SelectionIndent = 0
RichTextBox1.SelectedText = "No indenation is applied to this paragraph. All text in the paragraph flows from each control edge."
End Sub
備註
若目前未選取任何文字,縮排設定會套用到插入點所在段落及插入點後輸入控制項的所有文字。 縮排設定會持續使用,直到屬性被更改為其他值,或插入點被移至控制項內的其他段落。
若在控制項內選取文字,所選文字及後輸入的任何文字都會套用此屬性的值。 你可以利用此特性縮排文件中 RichTextBox段落。 你可以將此特性與 結合 SelectionRightIndent ,建立以段落形式顯示的段落。
若要在控制項中為段落建立懸掛縮排,請使用該 SelectionHangingIndent 屬性。