MaskedTextBox.TypeValidationCompleted イベントとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > MaskedTextBox.TypeValidationCompleted イベントの意味・解説 

MaskedTextBox.TypeValidationCompleted イベント

メモ : このイベントは、.NET Framework version 2.0新しく追加されたものです。

MaskedTextBox が ValidatingType プロパティ使用して現在の値の解析完了した場合発生します

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

Public Event TypeValidationCompleted As
 TypeValidationEventHandler
Dim instance As MaskedTextBox
Dim handler As TypeValidationEventHandler

AddHandler instance.TypeValidationCompleted, handler
public event TypeValidationEventHandler TypeValidationCompleted
public:
event TypeValidationEventHandler^ TypeValidationCompleted {
    void add (TypeValidationEventHandler^ value);
    void remove (TypeValidationEventHandler^ value);
}
/** @event */
public void add_TypeValidationCompleted (TypeValidationEventHandler
 value)

/** @event */
public void remove_TypeValidationCompleted
 (TypeValidationEventHandler value)
JScript では、イベント使用できますが、新規に宣言することはできません。
解説解説

MaskedTextBox コントロールは、MaskedTextBox.ValidatingType プロパティ定義された型に対してオプションユーザー入力検証します。このプロパティnull 参照 (Visual Basic では Nothing) 以外の場合次の一連のイベント発生します

  1. 検証シーケンスは、次のいずれか発生したときに開始します

  2. これらのイベント発生すると、ValidatingType プロパティ指定された型の Parse メソッド呼び出されます。書式設定された入力文字列は、Parse によって目的の型に変換されます。変換成功した場合、それは検証成功したのと同義です。

  3. Parse から制御が戻ると、TypeValidationCompleted イベント発生します。このイベントイベント ハンドラは、通常は型またはマスク検証処理を実行するために実装されます。このイベント ハンドラは、変換に関する情報格納する TypeValidationEventArgs パラメータ受け取ります。たとえば、IsValidInput メンバは、変換正常に行われたかどうか示します

  4. TypeValidationCompleted イベントイベント ハンドラから制御が戻ると、標準検証イベントである Validating が発生しますイベントキャンセルなど、標準検証実行するためのハンドラ実装できます

  5. 手順 3 でイベントキャンセルされなかった場合は、標準コントロール検証イベントである Validated が発生します

TypeValidationCompleted イベント ハンドラCancel プロパティtrue設定されている場合後続Validating イベントがこのイベントバージョンの CancelEventArgs.Cancel プロパティfalse戻さない限りイベントキャンセルされMaskedTextBox コントロールフォーカス保持します

使用例使用例

ユーザー入力有効な DateTime オブジェクトとして解析するコード例次に示します失敗した場合TypeValidationCompleted イベント ハンドラユーザーエラー メッセージ表示します。値が有効な DateTime場合指定され日付今日の日付より前でないことが確認されます。このコード例は、Windows フォーム プロジェクトに、MaskedTextBox1 という名前の MaskedTextBox コントロールと、ToolTip1 という名前の ToolTip コントロール配置されていることを前提としています。

Private Sub Form1_Load(ByVal
 sender As System.Object, ByVal e As
 System.EventArgs) Handles MyBase.Load
    Me.MaskedTextBox1.Mask = "00/00/0000"
    Me.MaskedTextBox1.ValidatingType = GetType(System.DateTime)

    Me.ToolTip1.IsBalloon = True
End Sub

Private Sub MaskedTextBox1_TypeValidationCompleted(ByVal
 sender As Object, ByVal
 e As TypeValidationEventArgs) Handles MaskedTextBox1.TypeValidationCompleted
    If (Not e.IsValidInput) Then
        Me.ToolTip1.ToolTipTitle = "Invalid
 Date"
        Me.ToolTip1.Show("The data you supplied
 must be a valid date in the format mm/dd/yyyy.", Me.MaskedTextBox1,
 Me.MaskedTextBox1.Location.X, Me.MaskedTextBox1.Location.Y, 5000)
    Else
        ' Now that the type has passed basic type validation, enforce
 more specific type rules.
        Dim UserDate As DateTime = CDate(e.ReturnValue)
        If (UserDate < DateTime.Now) Then
            Me.ToolTip1.ToolTipTitle = "Invalid
 Date"
            Me.ToolTip1.Show("The date
 in this field must be greater than today's date.",
 Me.MaskedTextBox1, Me.MaskedTextBox1.Location.X, Me.MaskedTextBox1.Location.Y, 5000)
            e.Cancel = True
        End If
    End If
End Sub

' Hide the tooltip if the user starts typing again before the five-second
 display limit on the tooltip expires.
Private Sub MaskedTextBox1_KeyDown(ByVal
 sender As Object, ByVal
 e As KeyEventArgs) Handles MaskedTextBox1.KeyDown
    Me.ToolTip1.Hide(Me.MaskedTextBox1)
End Sub
private void Form1_Load(object sender, EventArgs
 e)
{
    maskedTextBox1.Mask = "00/00/0000";
    maskedTextBox1.ValidatingType = typeof(System.DateTime);
    maskedTextBox1.TypeValidationCompleted += new TypeValidationEventHandler(maskedTextBox1_TypeValidationCompleted);
    maskedTextBox1.KeyDown += new KeyEventHandler(maskedTextBox1_KeyDown);

    toolTip1.IsBalloon = true;
}

void maskedTextBox1_TypeValidationCompleted(object sender, TypeValidationEventArgs
 e)
{
    if (!e.IsValidInput)
    {
        toolTip1.ToolTipTitle = "Invalid Date";
        toolTip1.Show("The data you supplied must be a valid date in
 the format mm/dd/yyyy.", maskedTextBox1, maskedTextBox1.Location.X, maskedTextBox1.Location.Y,
 5000);
    }
    else
    {
        //Now that the type has passed basic type validation, enforce
 more specific type rules.
        DateTime userDate = (DateTime)e.ReturnValue;
        if (userDate < DateTime.Now)
        {
            toolTip1.ToolTipTitle = "Invalid Date";
            toolTip1.Show("The date in this
 field must be greater than today's date.", maskedTextBox1, maskedTextBox1.Location.X,
 maskedTextBox1.Location.Y, 5000);
            e.Cancel = true;
        }
    }
}

// Hide the tooltip if the user starts typing again before the five-second
 display limit on the tooltip expires.
void maskedTextBox1_KeyDown(object sender, KeyEventArgs e)
{
    toolTip1.Hide(maskedTextBox1);
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
MaskedTextBox クラス
MaskedTextBox メンバ
System.Windows.Forms 名前空間
MaskedTextBox.Text プロパティ
ValidateText
MaskedTextBox.ValidatingType プロパティ
TypeValidationEventArgs


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

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

辞書ショートカット

すべての辞書の索引

「MaskedTextBox.TypeValidationCompleted イベント」の関連用語

MaskedTextBox.TypeValidationCompleted イベントのお隣キーワード
検索ランキング

   

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



MaskedTextBox.TypeValidationCompleted イベントのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS