Click here to Skip to main content
15,896,154 members
Articles / Programming Languages / C#

TextBoxRegex - A Text Box with Data Validation

Rate me:
Please Sign up or sign in to vote.
4.46/5 (13 votes)
29 Jun 2010CPOL7 min read 146.9K   1.8K   122  
An enhanced text box control with powerful data validation capabilities
#region Copyright (c) 2004 Marek Grzenkowicz
/*
 * Copyright (c) 2004 Marek Grzenkowicz
 * 
 * This software is provided 'as-is', without any warranty.
 * 
 * Permission is granted to anyone to use this software for any purpose.
 * 
 * This notice may not be removed from any source distibution; if you are
 * using this software in a product, this notice should be included in
 * materials distributed with your product.
 */
#endregion

using System;
using System.Runtime.Serialization;

namespace Chopeen
{
    /// <summary>
    /// <para>The exception that is thrown by <see cref="TextBoxRegex"/> control when its <see cref="TextBoxRegex.TextValidated"/>
    /// property is used to read the text that does not match the chosen pattern.</para>
    /// </summary>
    [Serializable]
    public class InvalidTextException : Exception
    {
        /// <summary>
        /// <para>Initializes a new instance of the <see cref="InvalidTextException"/> class.</para>
        /// </summary>
        public InvalidTextException() : base()
        {
        }

        /// <summary>
        /// <para>Initializes a new instance of the <see cref="InvalidTextException"/> class with a specified error message.</para>
        /// </summary>
        /// <param name="message">The message that describes the error.</param>
        public InvalidTextException(string message) : base(message)
        {
        }

        /// <summary>
        /// <para>Initializes a new instance of the <see cref="InvalidTextException"/> class with a specified error message
        /// and a reference to the inner exception that is the cause of this exception.</para>
        /// </summary>
        /// <param name="message">The message that describes the error.</param>
        /// <param name="innerException">The exception that is the cause of the current exception. If the innerException
        /// parameter is not a null reference (<b>Nothing</b> in Visual Basic), the current exception is raised in a catch block
        /// that handles the inner exception.</param>
        public InvalidTextException(string message, System.Exception innerException) : base(message, innerException)
        {
        }

        /// <summary>
        /// <para>Initializes a new instance of the <see cref="InvalidTextException"/> class with serialized data.</para>
        /// </summary>
        /// <param name="info">The <see cref="System.Runtime.Serialization.SerializationInfo"/> that holds
        /// the serialized object data about the exception being thrown.</param>
        /// <param name="context">The <see cref="System.Runtime.Serialization.StreamingContext"/> that contains
        /// contextual information about the source or destination.</param>
        protected InvalidTextException(SerializationInfo info, StreamingContext context) : base (info, context)
        {
        }
    }
}

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
Poland Poland
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions