Export (0) Print
Expand All

MaskedTextBox.MaskFull Property

Gets a value indicating whether all required and optional inputs have been entered into the input mask.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

<BrowsableAttribute(False)> _
Public ReadOnly Property MaskFull As Boolean

Property Value

Type: System.Boolean
true if all required and optional inputs have been entered; otherwise, false.

You can use the MaskFull property within the MaskInputRejected event handler to determine if the user's input was rejected because there are no remaining inputs in the mask. To determine whether only required input elements have been entered, use the MaskCompleted property.

The following code example handles the MaskInputRejected event, and uses a ToolTip to alert the user if an attempt is made to enter data after all positions in the mask have been used.

Private Sub MaskedTextBox1_MaskInputRejected(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MaskInputRejectedEventArgs) Handles MaskedTextBox1.MaskInputRejected
    If (Me.MaskedTextBox1.MaskFull) Then
        ToolTip1.ToolTipTitle = "Input Rejected - Too Much Data"
        ToolTip1.Show("You cannot enter any more data into the date field. Delete some characters in order to insert more data.", Me.MaskedTextBox1, Me.MaskedTextBox1.Location.X, Me.MaskedTextBox1.Location.Y, 5000)
    ElseIf (e.Position = Me.MaskedTextBox1.Mask.Length) Then
        ToolTip1.ToolTipTitle = "Input Rejected - End of Field"
        ToolTip1.Show("You cannot add extra characters to the end of this date field.", Me.MaskedTextBox1, 0, -20, 5000)
        ToolTip1.ToolTipTitle = "Input Rejected"
        ToolTip1.Show("You can only add numeric characters (0-9) into this date field.", Me.MaskedTextBox1, 0, -20, 5000)
    End If 
End Sub 

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Me.ToolTip1.IsBalloon = True 
    Me.MaskedTextBox1.Mask = "00/00/0000" 
End Sub 

Private Sub MaskedTextBox1_KeyDown(ByVal sender As Object, ByVal e As KeyEventArgs) Handles MaskedTextBox1.KeyDown
    ' The balloon tip is visible for five seconds; if the user types any data before it disappears, collapse it ourselves. 
End Sub

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
© 2015 Microsoft