次の方法で共有


RichTextBox.SelectionRightIndent プロパティ

RichTextBox コントロールの右端から、選択されているテキストの右端または現在のカーソル位置に追加されたテキストの右端までの距離 (ピクセル単位)。

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

構文

'宣言
Public Property SelectionRightIndent As Integer
'使用
Dim instance As RichTextBox
Dim value As Integer

value = instance.SelectionRightIndent

instance.SelectionRightIndent = value
public int SelectionRightIndent { get; set; }
public:
property int SelectionRightIndent {
    int get ();
    void set (int value);
}
/** @property */
public int get_SelectionRightIndent ()

/** @property */
public void set_SelectionRightIndent (int value)
public function get SelectionRightIndent () : int

public function set SelectionRightIndent (value : int)

プロパティ値

現在選択されている内容の右、またはカーソル位置の右に挿入されるインデント幅 (ピクセル単位)。

解説

テキストが現在選択されていない場合、インデントの設定は、カーソルがある段落と、カーソル位置以降にコントロールに入力されるすべてのテキストに適用されます。プロパティの値が変更されるまで、またはカーソル位置をコントロール内の別の段落に移動するまでの間は、このインデントの設定が適用されます。

コントロール内でテキストが選択されている場合は、選択されているテキスト、およびテキストを選択した後に入力したすべてのテキストに対して、このプロパティの値が適用されます。このプロパティを使用して、RichTextBox のドキュメント内に含まれている段落のインデントを設定できます。このプロパティを SelectionIndent と組み合わせて使用すると、段落内に表示される段落を作成できます。

コントロール内の段落にぶら下げインデントを設定するには、SelectionHangingIndent プロパティを使用します。

使用例

SelectionRightIndent プロパティを使用して RichTextBox 内に右端余白を作成する方法を次のコード例に示します。この例では、richTextBox1 という名前の RichTextBox コントロールがフォームに配置されており、このフォームのクラス内のイベントからこの例のコードが呼び出される必要があります。

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 right indent in all paragraphs.
   RichTextBox1.SelectionRightIndent = 20
   ' Set the text within the control.
   RichTextBox1.SelectedText = "All text is indented 20 pixels from the right edge of the RichTextBox."
   RichTextBox1.SelectedText = "You can use this property with the SelectionIndent property to provide right and left margins."
   RichTextBox1.SelectedText = "After this paragraph the indentation will end." + ControlChars.CrLf
   ' Remove all right indentation.
   RichTextBox1.SelectionRightIndent = 0
   RichTextBox1.SelectedText = "This paragraph has no right indentation. All text should flow as normal."
End Sub
private void WriteIndentedTextToRichTextBox()
{
    // Clear all text from the RichTextBox;
    richTextBox1.Clear();
    // Specify a 20 pixel right indent in all paragraphs.
      richTextBox1.SelectionRightIndent = 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 right edge of the RichTextBox.";
    richTextBox1.SelectedText = "You can use this property with the SelectionIndent property to provide right and left margins.";
    richTextBox1.SelectedText = "After this paragraph the indentation will end.\n\n";
    // Remove all right indentation.
    richTextBox1.SelectionRightIndent = 0;
    richTextBox1.SelectedText = "This paragraph has no right indentation. All text should flow as normal.";
}
private:
   void WriteIndentedTextToRichTextBox()
   {
      // Clear all text from the RichTextBox;
      richTextBox1->Clear();

      // Specify a 20 pixel right indent in all paragraphs.
      richTextBox1->SelectionRightIndent = 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 right edge of the RichTextBox.";
      richTextBox1->SelectedText = "You can use this property with the SelectionIndent property to provide right and left margins.";
      richTextBox1->SelectedText = "After this paragraph the indentation will end.\n\n";

      // Remove all right indentation.
      richTextBox1->SelectionRightIndent = 0;
      richTextBox1->SelectedText = "This paragraph has no right indentation. All text should flow as normal.";
   }
private void WriteIndentedTextToRichTextBox()
{
    // Clear all text from the RichTextBox;
    richTextBox1.Clear();
    // Specify a 20 pixel right indent in all paragraphs.
    richTextBox1.set_SelectionRightIndent(20);
    // Set the font for the text.
    richTextBox1.set_Font(new Font("Lucinda Console", 12));
    // Set the text within the control.
    richTextBox1.set_SelectedText("All text is indented 20 pixels from the "
        + "right edge of the RichTextBox.");
    richTextBox1.set_SelectedText("You can use this property with the "
        + "SelectionIndent property to provide right and left margins.");
    richTextBox1.set_SelectedText("After this paragraph the indentation "
        + "will end.\n\n");
    // Remove all right indentation.
    richTextBox1.set_SelectionRightIndent(0);
    richTextBox1.set_SelectedText("This paragraph has no right indentation."
        + "All text should flow as normal.");
} //WriteIndentedTextToRichTextBox

プラットフォーム

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。

バージョン情報

.NET Framework

サポート対象 : 2.0、1.1、1.0

参照

関連項目

RichTextBox クラス
RichTextBox メンバ
System.Windows.Forms 名前空間