本文整理匯總了VB.NET中System.Windows.Forms.MaskedTextBox.TypeValidationCompleted事件的典型用法代碼示例。如果您正苦於以下問題:VB.NET MaskedTextBox.TypeValidationCompleted事件的具體用法?VB.NET MaskedTextBox.TypeValidationCompleted怎麽用?VB.NET MaskedTextBox.TypeValidationCompleted使用的例子?那麽, 這裏精選的事件代碼示例或許可以為您提供幫助。您也可以進一步了解該事件所在類System.Windows.Forms.MaskedTextBox
的用法示例。
在下文中一共展示了MaskedTextBox.TypeValidationCompleted事件的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: GetType
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, 0, -20, 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, 0, -20, 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