RichTextBox.RightMargin 屬性

定義

取得或設定 RichTextBox 控制項內單行文字的大小。

public:
 property int RightMargin { int get(); void set(int value); };
public int RightMargin { get; set; }
member this.RightMargin : int with get, set
Public Property RightMargin As Integer

屬性值

Int32

控制項內單行文字的大小,以像素為單位。 預設值是零。

例外狀況

指定的值小於零。

範例

下列程式碼範例示範如何建立 RichTextBox 放大文字的 ,並在按兩下單字時自動選取控制項文字中的文字,並在控制項的工作區右側有邊界。 RichTextBox如果控制項的寬度很小,使用此程式碼會建立 , RichTextBox 其中每一個字元的文字都會顯示在自己的行上。 在這個垂直顯示位置中,按一下單字的任何部分將會選取單字的所有字元,而不論文字垂直顯示的事實為何。 此範例需要您有一個表單,其中包含 RichTextBox 名為 的 richTextBox1 控制項。

private:
   void ZoomMyRichTextBox()
   {
      // Enable users to select entire word when double clicked.
      richTextBox1->AutoWordSelection = true;

      // Clear contents of control.
      richTextBox1->Clear();

      // Set the right margin to restrict horizontal text.
      richTextBox1->RightMargin = 2;

      // Set the text for the control.
      richTextBox1->SelectedText = "Alpha Bravo Charlie Delta Echo Foxtrot";

      // Zoom by 2 points.
      richTextBox1->ZoomFactor = 2.0f;
   }
private void ZoomMyRichTextBox()
{
    // Enable users to select entire word when double clicked.
    richTextBox1.AutoWordSelection = true;
    // Clear contents of control.
    richTextBox1.Clear();
    // Set the right margin to restrict horizontal text.
    richTextBox1.RightMargin = 2;
    // Set the text for the control.
    richTextBox1.SelectedText = "Alpha Bravo Charlie Delta Echo Foxtrot";
    // Zoom by 2 points.
    richTextBox1.ZoomFactor = 2.0f;
}
Private Sub ZoomMyRichTextBox()
    ' Enable users to select entire word when double clicked.
    richTextBox1.AutoWordSelection = True
    ' Clear contents of control.
    richTextBox1.Clear()
    ' Set the right margin to restrict horizontal text.
    richTextBox1.RightMargin = 2
    ' Set the text for the control.
    richTextBox1.SelectedText = "Alpha Bravo Charlie Delta Echo Foxtrot"
    ' Zoom by 2 points.
    richTextBox1.ZoomFactor = 2.0F
End Sub

備註

當控制項中輸入大於零的值時,控制項中會以控制項左邊的指定圖元數目放置非可見邊界。 任何超出此邊界的輸入文字,都放在 控制項的下一行文字上。 此屬性會影響控制項中目前輸入的所有文字,以及設定 屬性之後輸入控制項的任何其他文字。 您可以使用這個屬性來指定控制項中 RichTextBox 輸入之所有文字的最大行寬。

適用於