Bagikan melalui


RichTextBox.SelectionHangingIndent Properti

Definisi

Mendapatkan atau mengatur jarak antara tepi kiri baris pertama teks dalam paragraf yang dipilih dan tepi kiri baris berikutnya dalam paragraf yang sama.

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

Nilai Properti

Jarak, dalam piksel, untuk inden gantung yang diterapkan ke pilihan teks saat ini atau titik penyisipan.

Atribut

Contoh

Contoh kode berikut menunjukkan cara menentukan inden gantung dalam RichTextBox menggunakan SelectionHangingIndent properti . Contoh ini mengharuskan RichTextBox kontrol, bernama richTextBox1, telah ditambahkan ke formulir.

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

Keterangan

Jika saat ini tidak ada teks yang dipilih, inden gantung diterapkan ke paragraf tempat titik penyisipan muncul dan ke semua teks yang diketik ke dalam kontrol setelah titik penyisipan. Pengaturan inden gantung berlaku hingga properti diubah ke nilai yang berbeda atau hingga titik penyisipan dipindahkan ke paragraf yang berbeda dalam kontrol.

Jika teks dipilih dalam kontrol, teks yang dipilih dan teks apa pun yang dimasukkan setelah pemilihan teks akan memiliki nilai properti ini yang diterapkan padanya. Anda dapat menggunakan properti ini untuk menerapkan inden gantung ke paragraf Anda.

Untuk mengatur indentasi baris pertama dari pilihan paragraf, gunakan SelectionIndent properti .

Berlaku untuk

Lihat juga