RichTextBox コントロール内の単一行のテキストのサイズを取得または設定します。
Public Property RightMargin As Integer
[C#]
public int RightMargin {get; set;}
[C++]
public: __property int get_RightMargin();public: __property void set_RightMargin(int);
[JScript]
public function get RightMargin() : int;public function set RightMargin(int);
プロパティ値
コントロール内の単一行のテキストのサイズ (ピクセル単位)。既定値は 0 です。
例外
例外の種類 | 条件 |
---|---|
ArgumentException | 指定した値が 0 未満でした。 |
解説
コントロールに 0 を超える値を入力すると、コントロールの左端から指定したピクセル数までの部分が、目に見えない余白として設定されます。この余白を超えて入力されたテキストは、コントロール内のテキストの次の行に表示されます。このプロパティは、その値を設定した後でコントロールに入力されたテキストだけではなく、現在入力されているすべてのテキストに適用されます。このプロパティを使用すると、 RichTextBox コントロールに入力されるすべてのテキストについて行の最大幅を指定できます。
使用例
[Visual Basic, C#, C++] テキストが拡大表示され、コントロールのテキスト内の単語がダブルクリックされたときに単語が自動的に選択され、コントロールのクライアント領域の右側に余白がある RichTextBox を作成する方法を次の例に示します。 RichTextBox コントロールの幅が小さい場合にこのコードを使用すると、テキストが見かけ上 1 行に 1 文字だけ表示される RichTextBox が作成されます。この垂直表示位置の場合、単語の任意の部分をクリックすると、テキストが縦書きで表示されていることにかかわらず、単語のすべての文字が選択されます。この例は、 richTextBox1
という名前の RichTextBox コントロールがフォームに配置されていることを前提にしています。
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
[C#]
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;
}
[C++]
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 = S"Alpha Bravo Charlie Delta Echo Foxtrot";
// Zoom by 2 points.
richTextBox1->ZoomFactor = 2.0f;
}
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ
参照
RichTextBox クラス | RichTextBox メンバ | System.Windows.Forms 名前空間