RichTextBox.MaxLength プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > RichTextBox.MaxLength プロパティの意味・解説 

RichTextBox.MaxLength プロパティ

ユーザーがリッチ テキスト ボックス コントロールに入力または貼り付けできる最大文字数を取得または設定します。

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

Public Overrides Property
 MaxLength As Integer
Dim instance As RichTextBox
Dim value As Integer

value = instance.MaxLength

instance.MaxLength = value
public override int MaxLength { get;
 set; }
/** @property */
public int get_MaxLength ()

/** @property */
public void set_MaxLength (int
 value)

プロパティ値
コントロールに入力できる文字数。既定値は MaxValue です。

例外例外
例外の種類条件

ArgumentException

プロパティに代入された値が 0 未満です。

解説解説
使用例使用例

MaxLength プロパティを使用して、RichTextBox コントロールに割り当てられているテキストが MaxLength プロパティで指定した値よりも長いかどうかを確認する方法を次のコード例に示します。この例では、テキストの方が長くない場合は、SelectedText プロパティを使用してコントロールにテキストを割り当てます。この例では、richTextBox1 という名前の RichTextBox コントロールがフォームに追加されており、この例のメソッドがコントロール内に貼り付けられるテキストをパラメータに指定して呼び出される必要があります。また、RichTextBox へのテキスト入力を制限する値を MaxLength プロパティに設定する必要もあります。

Private Sub AddMyText(ByVal
 textToAdd As String)
    ' Determine if the text to add is larger than the max length property.
    If textToAdd.Length > richTextBox1.MaxLength Then
        ' Alert user text is too large.
        MessageBox.Show("The text is too large to addo to the
 RichTextBox")
        ' Add the text to be added to the control.
    Else
        richTextBox1.SelectedText = textToAdd
    End If
End Sub
private void AddMyText(string
 textToAdd)
{
    // Determine if the text to add is larger than the max length property.
    if (textToAdd.Length > richTextBox1.MaxLength)
        // Alert user text is too large.
        MessageBox.Show("The text is too large to addo to the RichTextBox");
    else
        // Add the text to be added to the control.
        richTextBox1.SelectedText = textToAdd;
}
private:
   void AddMyText( String^ textToAdd )
   {
      // Determine if the text to add is larger than the max length
 property.
      if ( textToAdd->Length > richTextBox1->MaxLength
 )
         // Alert user text is too large.
         MessageBox::Show( "The text is too large to add to the RichTextBox"
 ); // Add the text to be added to the control.
      else
         richTextBox1->SelectedText = textToAdd;
   }
private void AddMyText(String textToAdd)
{
    // Determine if the text to add is larger than the max length property.
    if (textToAdd.get_Length() > richTextBox1.get_MaxLength())
 {
        // Alert user text is too large.
        MessageBox.Show("The text is too large to addo to the RichTextBox");
    } 
    else {
        // Add the text to be added to the control.
        richTextBox1.set_SelectedText(textToAdd);
    }
} //AddMyText 
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からRichTextBox.MaxLength プロパティを検索した結果を表示しています。
Weblioに収録されているすべての辞書からRichTextBox.MaxLength プロパティを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からRichTextBox.MaxLength プロパティ を検索

英和和英テキスト翻訳

英語⇒日本語日本語⇒英語

辞書ショートカット

すべての辞書の索引

RichTextBox.MaxLength プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



RichTextBox.MaxLength プロパティのページの著作権

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2026 Microsoft.All rights reserved.

©2026 GRAS Group, Inc.RSS