You got to the point of using the Validator. Run your form, and when you enter an invalid value in the TextBox, it will show an error message. You click the "Submit" button, it will not close the window while there are still errors. For a full demo, I have got a "register" example for you, please analyse it yourself. If you have any problems, feel free to contact me. Points of Interest In this section, I want to say more about advanced components programming.
It will be a guide to people who are interested in my Validator component and will show the key points of the Validator. Here, I will assume you that have basic components programming skills, like creating a component class, applying DefaultValue, DefaultEvent, and Browsable attributes, and so on.
Extend property ErrorProvider, ToolTip, and Validator - these components provide a mechanism which extends controls' or components' properties, in the property window. You will see text like "Type on validator1", which means Type property is an extended property and is provided by the validator1 control or component.
To have this amazing feature: The component must implement the IExtenderProvider interface. Returns whether or not the provider can provide an Extender for the given object in the specified category. In Validator, I define an extended property for the control. Actually, a property window only provides a simple text input editor as default.
How do Color and Lines properties do this? Using the Reflector v4. Color struct in the System. If class A applies the Editor attrubute, any other class can define properties of class A. Those properties will always be edited by the specified editor in the property window.
Only those properties which apply the Editor attrubute will be edited by the specified editor; although other property types are same, they will be edited by the default simple text box.
Like the RegexOptions enum, you can choose the bit value set using logic OR , or click the "None" button to set enum value to 0. For details, you can refer to MSDN. Secondly, it drops down a user control which has a "None" button to set the enum value to 0, and has several check list items each of which represents one enumeration member except "None". Component Designer Have you noticed that, if you set the focus on a ListView control at design time, there appears a triangle button on it.
When you click it, it will show a context menu. Besides, when you drop a ErrorProvider to a Form, it will automatically generate a line like: In Validator, I apply the Design attribute: History April 11th, - First version. Bo Shen, who checks my article and corrects my English. 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 Share.