Export (0) Print
Expand All

MaskedTextBox.MaskFull Property

Note: This property is new in the .NET Framework version 2.0.

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)

public bool MaskFull { get; }
/** @property */
public boolean get_MaskFull ()

public function get MaskFull () : boolean

Property Value

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 void Form1_Load(object sender, EventArgs e)
{
    maskedTextBox1.Mask = "00/00/0000";

    maskedTextBox1.MaskInputRejected += new MaskInputRejectedEventHandler(maskedTextBox1_MaskInputRejected);
    maskedTextBox1.KeyDown += new KeyEventHandler(maskedTextBox1_KeyDown);
}

void maskedTextBox1_MaskInputRejected(object sender, MaskInputRejectedEventArgs e)
{
    if (maskedTextBox1.MaskFull)
    {
        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.", maskedTextBox1, maskedTextBox1.Location.X, maskedTextBox1.Location.Y, 5000);
    }
    else if (e.Position == maskedTextBox1.Mask.Length)
    {
        toolTip1.ToolTipTitle = "Input Rejected - End of Field";
        toolTip1.Show("You cannot add extra characters to the end of this date field.", maskedTextBox1, maskedTextBox1.Location.X, maskedTextBox1.Location.Y, 5000);
    }
    else
    {
        toolTip1.ToolTipTitle = "Input Rejected";
        toolTip1.Show("You can only add numeric characters (0-9) into this date field.", maskedTextBox1, maskedTextBox1.Location.X, maskedTextBox1.Location.Y, 5000);
    }
}

void maskedTextBox1_KeyDown(object sender, KeyEventArgs e)
{
    // The balloon tip is visible for five seconds; if the user types any data before it disappears, collapse it ourselves.
    toolTip1.Hide(maskedTextBox1);
}

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0

Community Additions

ADD
Show:
© 2014 Microsoft