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

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

TextBoxBase.MaxLength プロパティ

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

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

<LocalizableAttribute(True)> _
Public Overridable Property
 MaxLength As Integer
Dim instance As TextBoxBase
Dim value As Integer

value = instance.MaxLength

instance.MaxLength = value
[LocalizableAttribute(true)] 
public virtual int MaxLength { get;
 set; }
[LocalizableAttribute(true)] 
public:
virtual property int MaxLength {
    int get ();
    void set (int value);
}
/** @property */
public int get_MaxLength ()

/** @property */
public void set_MaxLength (int
 value)
public function get MaxLength
 () : int

public function set MaxLength
 (value : int)

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

例外例外
例外種類条件

ArgumentOutOfRangeException

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

解説解説

このプロパティ使用すると、郵便番号電話番号などの値を入力するコントロールテキスト長さや、データベースデータ入力するときのテキスト長さ制限できますコントロール入力するテキスト長さを、データベース該当フィールド最大長さ以下に制限できます

メモメモ

コードでは、Text プロパティの値を MaxLength プロパティ指定した値よりも長い値に設定できます。このプロパティは、実行時コントロール入力されるテキストにだけ影響します

Windows NT 4.0, Windows 2000, Windows 2000 Professional, Windows 2000 Server, Windows 2000 Advanced Server, Windows XP Home Edition, Windows XP Professional x64 Edition, Windows Server 2003 プラットフォームメモ : 単一テキスト ボックス コントロールMaxLength プロパティを 0 に設定した場合ユーザー入力できる最大文字数は、2147483646 または使用可能なメモリ応じたサイズのうち、いずれか小さい数となります複数テキスト ボックス コントロール場合ユーザー入力できる最大文字数は、4294967295 または使用可能なメモリ応じたサイズのうち、いずれか小さい数となります

Windows Millennium Edition プラットフォームメモ : 単一テキスト ボックス コントロールMaxLength プロパティを 0 に設定した場合ユーザー入力できる最大文字数は、32,766 または使用可能なメモリ応じたサイズのうち、いずれか小さい数となります複数テキスト ボックス コントロール場合ユーザー入力できる最大文字数は、65,535 または使用可能なメモリ応じたサイズのうち、いずれか小さい数となります

使用例使用例

派生クラス TextBox使用してパスワード受け入れるために使用されるテキスト ボックス作成するコード例次に示します。この例では、CharacterCasing プロパティ使用して入力されすべての文字大文字変更しますまた、MaxLength プロパティ使用してパスワード長を 8 文字制限します。この例では、TextAlign プロパティ使用してTextBox コントロール中央パスワード配置します

Public Sub CreateMyPasswordTextBox()
    ' Create an instance of the TextBox control.
    Dim textBox1 As New
 TextBox()
    ' Set the maximum length of text in the control to eight.
    textBox1.MaxLength = 8
    ' Assign the asterisk to be the password character.
    textBox1.PasswordChar = "*"c
    ' Change all text entered to be uppercase.
    textBox1.CharacterCasing = CharacterCasing.Upper
    ' Align the text in the center of the TextBox control.
    textBox1.TextAlign = HorizontalAlignment.Center
End Sub
public void CreateMyPasswordTextBox()
 {
    // Create an instance of the TextBox control.
    TextBox textBox1 = new TextBox();
    // Set the maximum length of text in the control to eight.
    textBox1.MaxLength = 8;
    // Assign the asterisk to be the password character.
    textBox1.PasswordChar = '*';
    // Change all text entered to be uppercase.
    textBox1.CharacterCasing = CharacterCasing.Upper;
    // Align the text in the center of the TextBox control.
    textBox1.TextAlign = HorizontalAlignment.Center;
 }
public:
   void CreateMyPasswordTextBox()
   {
      // Create an instance of the TextBox control.
      TextBox^ textBox1 = gcnew TextBox;
      // Set the maximum length of text in the control to eight.
      textBox1->MaxLength = 8;
      // Assign the asterisk to be the password character.
      textBox1->PasswordChar = '*';
      // Change all text entered to be uppercase.
      textBox1->CharacterCasing = CharacterCasing::Upper;
      // Align the text in the center of the TextBox control.
      textBox1->TextAlign = HorizontalAlignment::Center;
   }
public void CreateMyPasswordTextBox()
{
    // Create an instance of the TextBox control.
    TextBox textBox1 = new TextBox();
    // Set the maximum length of text in the control to eight.
    textBox1.set_MaxLength(8);
    // Assign the asterisk to be the password character.
    textBox1.set_PasswordChar('*');
    // Change all text entered to be uppercase.
    textBox1.set_CharacterCasing(CharacterCasing.Upper);
    // Align the text in the center of the TextBox control.
    textBox1.set_TextAlign(HorizontalAlignment.Center);
} //CreateMyPasswordTextBox
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


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

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

辞書ショートカット

すべての辞書の索引

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

   

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



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

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

©2025 GRAS Group, Inc.RSS