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 プロパティ を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

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

   

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



RichTextBox.MaxLength プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS