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

プロパティ値

コントロール内の単一行のテキストのサイズ (ピクセル単位)。 既定値は 0 です。

例外

指定した値が 0 未満でした。

次のコード例は、テキストを拡大し、単語がダブルクリックされたときにコントロールのテキスト内の単語を自動的に選択し、コントロールのクライアント領域の右側に余白を持つ を作成 RichTextBox する方法を示しています。 コントロールの RichTextBox 幅が小さい場合、このコードを使用すると、 RichTextBox テキストの各文字が独自の行に表示される が作成されます。 この垂直方向の表示位置では、単語の任意の部分をクリックすると、テキストが垂直方向に表示されるという事実に関係なく、単語のすべての文字が選択されます。 この例では、 という名前richTextBox1のコントロールを含むフォームがRichTextBox必要です。

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

注釈

コントロールに 0 より大きい値を入力すると、コントロールの左側から指定したピクセル数に、非表示の余白がコントロールに配置されます。 この余白を超えて入力されたテキストは、コントロール内のテキストの次の行に配置されます。 このプロパティは、現在コントロールに入力されているすべてのテキストと、プロパティが設定された後にコントロールに入力された追加のテキストに影響します。 このプロパティを使用すると、コントロールに入力されたすべてのテキストの最大行幅を RichTextBox 指定できます。

適用対象