PowerTools CalendarGrid for Windows Forms 1.0J
MaxLength プロパティ (CalendarTextBoxCellType)
使用例 

セルに入力できる最大文字数を取得または設定します。
構文
Public Property MaxLength As Integer
public int MaxLength {get; set;}

プロパティ値

セルに入力できる最大文字数を表す System.Int32 値。既定値は 32767 です。
例外
例外解説
System.ArgumentOutOfRangeException指定された値が 0 未満です。
使用例
次のサンプルコードは、CalendarTextBoxCellType のいくつかの重要なプロパティを示します。セルにテキスト全体を表示できない場合、省略記号文字列 "......" が表示されます。HighlightText プロパティが true に設定されているため、編集モードに入るとテキストが選択されます。MaxLength は 10 なので、元のテキストを削除してテキストを入力する場合、10 文字だけ入力できます。大文字のテキストは小文字に変換されます。このサンプルコードは、CalendarTextBoxCellType クラスに示されている詳細なコード例の一部を抜粋したものです。
private void Form1_Load(object sender, EventArgs e)
{
    CalendarTextBoxCellType textBoxCell1 = new CalendarTextBoxCellType();
    //If the text cannot display completely, one '......' string will be shown at the text's end, hover the cell, the whole text will be shown in tool tip.
    textBoxCell1.Ellipsis = CalendarGridEllipsisMode.EllipsisEnd;
    textBoxCell1.EllipsisString = "......";
    //Enter the edit mode, the text will be highlight selected.
    textBoxCell1.HighlightText = true;
    textBoxCell1.MaxLength = 10;
    //The value will be casted to lower case.
    textBoxCell1.CharacterCasing = CharacterCasing.Lower;

    CalendarTextBoxCellType textBoxCell2 = new CalendarTextBoxCellType();
    //Input text in textBoxCell2, it will be treated as password, always display '#'.
    textBoxCell2.PasswordChar = '#';
    textBoxCell2.UseSystemPasswordChar = false;

    CalendarTemplate template1 = CalendarTemplate.CreateDefaultTemplate();
    template1.Content[1, 0].CellType = textBoxCell1;
    template1.Content[1, 0].Value = "DELETE THIS STRING TO INPUT BY YOURSELF, ONLY 10 CHARACTERS CAN BE INPUT";
    template1.Content[2, 0].CellType = textBoxCell2;
    template1.Content[2, 0].Value = "12345";

    gcCalendarGrid1.Template = template1;
}
Private Sub Form1_Load(sender As Object, e As EventArgs)
    Dim textBoxCell1 As New CalendarTextBoxCellType()
    'If the text cannot display completely, one '......' string will be shown at the text's end, hover the cell, the whole text will be shown in tool tip.
    textBoxCell1.Ellipsis = CalendarGridEllipsisMode.EllipsisEnd
    textBoxCell1.EllipsisString = "......"
    'Enter the edit mode, the text will be highlight selected.
    textBoxCell1.HighlightText = True
    textBoxCell1.MaxLength = 10
    'The value will be casted to lower case.
    textBoxCell1.CharacterCasing = CharacterCasing.Lower

    Dim textBoxCell2 As New CalendarTextBoxCellType()
    'Input text in textBoxCell2, it will be treated as password, always display '#'.
    textBoxCell2.PasswordChar = "#"c
    textBoxCell2.UseSystemPasswordChar = False

    Dim template1 As CalendarTemplate = CalendarTemplate.CreateDefaultTemplate()
    template1.Content(1, 0).CellType = textBoxCell1
    template1.Content(1, 0).Value = "DELETE THIS STRING TO INPUT BY YOURSELF, ONLY 10 CHARACTERS CAN BE INPUT"
    template1.Content(2, 0).CellType = textBoxCell2
    template1.Content(2, 0).Value = "12345"

    gcCalendarGrid1.Template = template1
End Sub
参照

CalendarTextBoxCellType クラス
CalendarTextBoxCellType メンバ

 

 


© 2014 GrapeCity inc. All rights reserved.