RichTextBox.SelectionHangingIndent 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定選取段落中第一行文字的左邊緣和同段落中其他各行左邊緣間的距離。
public:
property int SelectionHangingIndent { int get(); void set(int value); };
[System.ComponentModel.Browsable(false)]
public int SelectionHangingIndent { get; set; }
[<System.ComponentModel.Browsable(false)>]
member this.SelectionHangingIndent : int with get, set
Public Property SelectionHangingIndent As Integer
屬性值
套用於目前文字選取範圍或插入點的首行縮排距離 (以像素為單位)。
- 屬性
範例
下列程式碼範例示範如何使用 屬性,在 內 RichTextBox SelectionHangingIndent 指定停止縮排。 此範例要求 RichTextBox 已將名為 richTextBox1
的控制項新增至表單。
private:
void WriteIndentedTextToRichTextBox()
{
// Clear all text from the RichTextBox;
richTextBox1->Clear();
// Specify a 20 pixel hanging indent in all paragraphs.
richTextBox1->SelectionHangingIndent = 20;
// Set the font for the text.
richTextBox1->Font = gcnew System::Drawing::Font( "Lucinda Console",12 );
// Set the text within the control.
richTextBox1->SelectedText = "This text contains a hanging indent. The first sentence of the paragraph is spaced normally.";
richTextBox1->SelectedText = "All subsequent lines of text are indented based on the value of SelectionHangingIndent.";
richTextBox1->SelectedText = "After this paragraph the indent is returned to normal spacing.\n";
richTextBox1->SelectedText = "Since this is a new paragraph the indent is also applied to this paragraph.";
richTextBox1->SelectedText = "All subsequent lines of text are indented based on the value of SelectionHangingIndent.";
}
private void WriteIndentedTextToRichTextBox()
{
// Clear all text from the RichTextBox;
richTextBox1.Clear();
// Specify a 20 pixel hanging indent in all paragraphs.
richTextBox1.SelectionHangingIndent = 20;
// Set the font for the text.
richTextBox1.Font = new Font("Lucinda Console", 12);
// Set the text within the control.
richTextBox1.SelectedText = "This text contains a hanging indent. The first sentence of the paragraph is spaced normally.";
richTextBox1.SelectedText = "All subsequent lines of text are indented based on the value of SelectionHangingIndent.";
richTextBox1.SelectedText = "After this paragraph the indent is returned to normal spacing.\n";
richTextBox1.SelectedText = "Since this is a new paragraph the indent is also applied to this paragraph.";
richTextBox1.SelectedText = "All subsequent lines of text are indented based on the value of SelectionHangingIndent.";
}
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 hanging indent in all paragraphs.
RichTextBox1.SelectionHangingIndent = 20
' Set the text within the control.
RichTextBox1.SelectedText = "VBThis text contains a hanging indent. The first sentence of the paragraph is spaced normally."
RichTextBox1.SelectedText = "All subsequent lines of text are indented based on the value of SelectionHangingIndent."
RichTextBox1.SelectedText = "After this paragraph the indent is returned to normal spacing." + ControlChars.CrLf
RichTextBox1.SelectedText = "Since this is a new paragraph the indent is also applied to this paragraph."
RichTextBox1.SelectedText = "All subsequent lines of text are indented based on the value of SelectionHangingIndent."
End Sub
備註
如果目前未選取任何文字,則會將停止縮排套用至插入點出現所在的段落,以及插入點之後輸入控制項的所有文字。 停止縮排設定會套用到屬性變更為不同的值,或直到插入點移至控制項內的不同段落為止。
如果在控制項內選取文字,則選取的文字和在文字選取範圍之後輸入的任何文字都會套用此屬性的值。 您可以使用這個屬性,將停止縮排套用至段落。
若要設定段落選取範圍第一行的縮排,請使用 SelectionIndent 屬性。