Click here to Skip to main content
15,883,901 members
Articles / Desktop Programming / Windows Forms

Masked Label Control

Rate me:
Please Sign up or sign in to vote.
4.36/5 (5 votes)
27 Jun 2006CPOL5 min read 67.2K   726   28  
A derived label control that can format its text using the same mask characters as the MaskedTextBox control.
<?xml version="1.0"?>
<doc>
    <assembly>
        <name>EWSoftware.MaskedLabelControl</name>
    </assembly>
    <members>
        <member name="T:EWSoftware.MaskedLabelControl.MaskedLabel">
            <summary>
            This is a derived label control that can format its text using the same
            mask characters as the <see cref="T:System.Windows.Forms.MaskedTextBox"/> control.
            </summary>
        </member>
        <member name="M:EWSoftware.MaskedLabelControl.MaskedLabel.#ctor">
            <summary>
            Constructor
            </summary>
            <remarks>There is no mask applied by default</remarks>
        </member>
        <member name="M:EWSoftware.MaskedLabelControl.MaskedLabel.Format(System.String,System.String)">
            <summary>
            Format the specified text using the specified mask
            </summary>
            <param name="mask">The mask to use</param>
            <param name="text">The text to format</param>
            <returns>The formatted text string</returns>
            <overloads>There are four overloads for this method.</overloads>
        </member>
        <member name="M:EWSoftware.MaskedLabelControl.MaskedLabel.Format(System.String,System.String,System.Char)">
            <summary>
            Format the specified text using the specified mask and prompt
            character.
            </summary>
            <param name="mask">The mask to use.</param>
            <param name="text">The text to format.</param>
            <param name="promptChar">The prompt character to use for missing
            characters.  If a null character ('\x0') is specified, prompt
            characters are omitted.</param>
            <returns>The formatted text string.</returns>
        </member>
        <member name="M:EWSoftware.MaskedLabelControl.MaskedLabel.Format(System.String,System.String,System.Char,System.Globalization.CultureInfo)">
            <summary>
            Format the specified text using the specified mask, prompt
            character, and culture information.
            </summary>
            <param name="mask">The mask to use.</param>
            <param name="text">The text to format.</param>
            <param name="promptChar">The prompt character to use for missing
            characters.  If a null character ('\x0') is specified, prompt
            characters are omitted.</param>
            <param name="culture">The culture information to use.  If null,
            the current culture is used.</param>
            <returns>The formatted text string.</returns>
        </member>
        <member name="M:EWSoftware.MaskedLabelControl.MaskedLabel.Format(System.String,System.String,System.Char,System.Globalization.CultureInfo,System.ComponentModel.MaskedTextResultHint@,System.Int32@)">
            <summary>
            Format the specified text using the specified mask, prompt
            character, and culture information and return the result
            values.
            </summary>
            <param name="mask">The mask to use.</param>
            <param name="text">The text to format.</param>
            <param name="promptChar">The prompt character to use for missing
            characters.  If a null character ('\x0') is specified, prompt
            characters are omitted.</param>
            <param name="culture">The culture information to use.  If null,
            the current culture is used.</param>
            <param name="hint">The result of formatting the text.</param>
            <param name="hintPosition">The position related to the result
            hint.</param>
            <returns>The formatted text string.</returns>
        </member>
        <member name="P:EWSoftware.MaskedLabelControl.MaskedLabel.MaskedTextProvider">
            <summary>
            This returns a clone of the masked text provider currently being
            used by the masked label control.
            </summary>
        </member>
        <member name="P:EWSoftware.MaskedLabelControl.MaskedLabel.ResultHint">
            <summary>
            This returns the result hint for the last assignment to the
            <see cref="P:EWSoftware.MaskedLabelControl.MaskedLabel.Text"/> property.
            </summary>
            <remarks>If the assigned text could not be properly formatted,
            this will contain a hint as to why not.  Positive values
            indicate success.  Negative values indicate failure.</remarks>
        </member>
        <member name="P:EWSoftware.MaskedLabelControl.MaskedLabel.HintPosition">
            <summary>
            This returns the result hint position for the last assignment to
            the <see cref="P:EWSoftware.MaskedLabelControl.MaskedLabel.Text"/> property.
            </summary>
            <remarks>If the assigned text could not be properly formatted,
            this will contain the position of the first failure.</remarks>
        </member>
        <member name="P:EWSoftware.MaskedLabelControl.MaskedLabel.UnmaskedText">
            <summary>
            This read-only property returns the unmasked copy of the text
            </summary>
        </member>
        <member name="P:EWSoftware.MaskedLabelControl.MaskedLabel.Text">
            <summary>
            This is used to set or get the label text.
            </summary>
            <remarks>When set, the text is formatted according to the current
            masked text provider settings.  If the mask is empty, the text is
            set as-is.  When retrieved, the text is returned in its formatted
            state.  Use <see cref="P:EWSoftware.MaskedLabelControl.MaskedLabel.UnmaskedText"/> to get the text without
            the mask applied.</remarks>
        </member>
        <member name="P:EWSoftware.MaskedLabelControl.MaskedLabel.Culture">
            <summary>
            This is used to set or get the culture information associated with
            the masked label.
            </summary>
            <exception cref="T:System.ArgumentNullException">This is thrown if the
            culture value is null</exception>
        </member>
        <member name="P:EWSoftware.MaskedLabelControl.MaskedLabel.Mask">
            <summary>
            This is used to set or get the mask for the label text
            </summary>
        </member>
        <member name="P:EWSoftware.MaskedLabelControl.MaskedLabel.PromptChar">
            <summary>
            This is used to set or get the prompt character for display
            in the label text.
            </summary>
            <value>The default is an underscore (_).</value>
        </member>
        <member name="P:EWSoftware.MaskedLabelControl.MaskedLabel.IncludePrompt">
            <summary>
            This is used to set or get whether or not prompt characters are
            also displayed in the label text.
            </summary>
            <value>By default, prompt characters are not shown.</value>
        </member>
    </members>
</doc>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
United States United States
Eric Woodruff is an Analyst/Programmer for Spokane County, Washington where he helps develop and support various applications, mainly criminal justice systems, using Windows Forms (C#) and SQL Server as well as some ASP.NET applications.

He is also the author of various open source projects for .NET including:

The Sandcastle Help File Builder - A front end and project management system that lets you build help file projects using Microsoft's Sandcastle documentation tools. It includes a standalone GUI and a package for Visual Studio integration.

Visual Studio Spell Checker - A Visual Studio editor extension that checks the spelling of comments, strings, and plain text as you type or interactively with a tool window. This can be installed via the Visual Studio Gallery.

Image Map Controls - Windows Forms and web server controls that implement image maps.

PDI Library - A complete set of classes that let you have access to all objects, properties, parameter types, and data types as defined by the vCard (RFC 2426), vCalendar, and iCalendar (RFC 2445) specifications. A recurrence engine is also provided that allows you to easily and reliably calculate occurrence dates and times for even the most complex recurrence patterns.

Windows Forms List Controls - A set of extended .NET Windows Forms list controls. The controls include an auto-complete combo box, a multi-column combo box, a user control dropdown combo box, a radio button list, a check box list, a data navigator control, and a data list control (similar in nature to a continuous details section in Microsoft Access or the DataRepeater from VB6).

For more information see http://www.EWoodruff.us

Comments and Discussions