Bagikan melalui


RichTextBox.SelectionIndent Properti

Definisi

Mendapatkan atau mengatur panjang, dalam piksel, dari indentasi baris tempat pemilihan dimulai.

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

Nilai Properti

Jarak saat ini, dalam piksel, dari indentasi yang diterapkan di sebelah kiri pilihan teks saat ini atau titik penyisipan.

Atribut

Contoh

Contoh kode berikut menunjukkan cara menentukan teks yang diindentasi dalam RichTextBox menggunakan SelectionIndent 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 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

Keterangan

Jika saat ini tidak ada teks yang dipilih, pengaturan indentasi diterapkan ke paragraf tempat titik penyisipan muncul dan ke semua teks yang diketik ke dalam kontrol setelah titik penyisipan. Pengaturan indentasi 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 mengindentasi paragraf yang terkandung dalam dokumen RichTextBox. Anda dapat menggunakan properti ini bersama dengan SelectionRightIndent untuk membuat paragraf yang ditampilkan dalam paragraf.

Untuk membuat inden gantung untuk paragraf dalam kontrol, gunakan SelectionHangingIndent properti .

Berlaku untuk

Lihat juga