Click here to Skip to main content
15,886,362 members
Articles / Desktop Programming / Windows Forms

Validate user input in Windows Forms

Rate me:
Please Sign up or sign in to vote.
4.71/5 (50 votes)
26 Apr 20066 min read 427.7K   17.1K   129  
You needn't write any code for control validation; just set a control's validation information at design-time and reduce maintenance workload.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing.Design;
using System.Text;

namespace Itboy.Components
{
    /// <summary>
    /// ValidationMode, can use FocusChange and Submit combination.
    /// </summary>
    [Flags]
    [Editor(typeof(Itboy.Design.FlagsEditor), typeof(UITypeEditor))]
    public enum ValidationMode
    {
        /// <summary>
        /// None.
        /// </summary>
        None = 0x0000,
        /// <summary>
        /// Allow focus change to next control
        /// </summary>
        FocusChange = 0x0001,
        /// <summary>
        /// Validate controls when user click "OK" or "Yes" button.
        /// </summary>
        Submit = 0x0002,
    }
}

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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
China China
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions