Class RadValidationProvider
Provides a validation management framework for RadEditorControl descendant editors, enabling the creation and enforcement of validation rules with visual error indicators and tooltips.
Inheritance
Namespace: Telerik.WinControls.UI
Assembly: Telerik.WinControls.UI.dll
Syntax
[TelerikToolboxCategory("Editors")]
public class RadValidationProvider : Component, ISupportInitialize, IExtenderProvider
Constructors
RadValidationProvider()
Initializes a new instance of the RadValidationProvider class.
Declaration
public RadValidationProvider()
RadValidationProvider(IContainer)
Initializes a new instance of the RadValidationProvider class with the specified container control.
Declaration
public RadValidationProvider(IContainer container)
Parameters
System.ComponentModel.IContainer
container
An object that implements the System.ComponentModel.IContainer interface, and owns the created object. |
Properties
AssociatedControls
Gets a collection of all RadEditorControl instances that have validation rules associated with them.
Declaration
public List<RadEditorControl> AssociatedControls { get; }
Property Value
System.Collections.Generic.List<RadEditorControl>
|
ValidationMode
Gets or sets the validation mode that determines when validation should be triggered for associated controls.
Declaration
public ValidationMode ValidationMode { get; set; }
Property Value
ValidationMode
|
ValidationRules
Gets or sets the collection of validation rules that define the validation criteria for associated RadEditorControl instances.
Declaration
public FilterDescriptorCollection ValidationRules { get; set; }
Property Value
FilterDescriptorCollection
|
Methods
BeginInit()
Signals the start of initialization for the validation provider component.
Declaration
public void BeginInit()
CanExtend(Object)
Indicates whether a control can be extended by this provider. Specifies whether this object can provide its extender properties to the specified object.
Declaration
public bool CanExtend(object extendee)
Parameters
System.Object
extendee
The object to be checked for extension capability. |
Returns
System.Boolean
true if the object can be extended (is a RadEditorControl); otherwise false. |
ClearErrorStatus()
Clears the visual indication for validation errors on all associated controls.
Declaration
public virtual void ClearErrorStatus()
ClearErrorStatus(RadControl)
Clears the visual indication for validation errors on the specified control.
Declaration
public virtual void ClearErrorStatus(RadControl associatedControl)
Parameters
RadControl
associatedControl
A RadControl descendant for which to clear the error status. |
EndInit()
Signals the end of initialization for the validation provider component and ensures proper event subscription.
Declaration
public void EndInit()
FireValidationEvent(Boolean, RadControl, IRadValidationRule)
Creates and fires a validation event with the specified parameters and returns the configured event arguments.
Declaration
protected virtual RadValidationEventArgs FireValidationEvent(bool isNotValid, RadControl associatedControl, IRadValidationRule rule)
Parameters
System.Boolean
isNotValid
true if validation has failed; otherwise false. |
RadControl
associatedControl
The RadControl being validated. |
IRadValidationRule
rule
The IRadValidationRule that was evaluated. |
Returns
RadValidationEventArgs
A configured RadValidationEventArgs object containing validation results and settings. |
GetIconAlignment(RadEditorControl)
Gets the alignment of the error icon for the specified RadEditorControl.
Declaration
public ErrorIconAlignment GetIconAlignment(RadEditorControl control)
Parameters
RadEditorControl
control
A target RadEditorControl for which to retrieve the icon alignment. |
Returns
System.Windows.Forms.ErrorIconAlignment
An System.Windows.Forms.ErrorIconAlignment value representing the current alignment setting for the control. |
GetIconPadding(RadEditorControl)
Returns the amount of extra space to leave next to the error icon for the specified control.
Declaration
public Padding GetIconPadding(RadEditorControl control)
Parameters
RadEditorControl
control
The RadEditorControl to get the padding for. |
Returns
System.Windows.Forms.Padding
The padding to leave between the icon and the control. |
GetValidationRule(RadEditorControl)
Returns the first validation rule associated with the specified RadEditorControl descendant.
Declaration
public FilterDescriptor GetValidationRule(RadEditorControl control)
Parameters
RadEditorControl
control
A RadEditorControl descendant for which to retrieve the validation rule. |
Returns
FilterDescriptor
An IRadValidationRule that represents the validation rule associated with the editor, or null if no validation rule is associated with the specified control. |
OnControlValidation(RadValidationEventArgs)
Raises the ControlValidation event with the specified validation event arguments.
Declaration
protected virtual void OnControlValidation(RadValidationEventArgs e)
Parameters
RadValidationEventArgs
e
A RadValidationEventArgs that contains the event data. |
RemoveControlFromRules(RadEditorControl)
Removes a specific RadEditorControl from all validation rules in the provider.
Declaration
public void RemoveControlFromRules(RadEditorControl editorControl)
Parameters
RadEditorControl
editorControl
A RadEditorControl descendant to remove from all validation rules. |
RemoveRules(RadEditorControl)
Removes all validation rules associated with the specified RadEditorControl.
Declaration
public void RemoveRules(RadEditorControl control)
Parameters
RadEditorControl
control
A RadEditorControl descendant for which to remove all associated rules. |
RemoveValidationRule(RadEditorControl, IRadValidationRule)
Removes a specific validation rule association with the specified RadEditorControl descendant.
Declaration
public void RemoveValidationRule(RadEditorControl editorControl, IRadValidationRule ruleToRemove)
Parameters
RadEditorControl
editorControl
A RadEditorControl descendant to remove from the rule. |
IRadValidationRule
ruleToRemove
The validation rule to disassociate from the control. |
SetIconAlignment(RadEditorControl, ErrorIconAlignment)
Sets the alignment of the error icon for the specified RadEditorControl.
Declaration
public void SetIconAlignment(RadEditorControl control, ErrorIconAlignment errorIconAlignment)
Parameters
RadEditorControl
control
A target RadEditorControl for which to set the icon alignment. |
System.Windows.Forms.ErrorIconAlignment
errorIconAlignment
An System.Windows.Forms.ErrorIconAlignment value that specifies the alignment to be set for the control. |
SetIconPadding(RadEditorControl, Padding)
Sets the amount of extra space to leave between the specified control and the error icon.
Declaration
public void SetIconPadding(RadEditorControl control, Padding errorIconPadding)
Parameters
RadEditorControl
control
The RadEditorControl to set the padding for. |
System.Windows.Forms.Padding
errorIconPadding
The padding to add between the icon and the control. |
SetValidationRule(RadEditorControl, FilterDescriptor)
Associates a validation rule with the specified RadEditorControl descendant.
Declaration
public void SetValidationRule(RadEditorControl control, FilterDescriptor rule)
Parameters
RadEditorControl
control
A RadEditorControl descendant that represents the editor. |
FilterDescriptor
rule
An IRadValidationRule that represents the validation rule to associate. |
ShowToolTip(RadControl, String, String, Int32, Int32, Int32, Boolean)
Shows a custom tooltip for validation errors with the specified parameters and styling.
Declaration
protected virtual void ShowToolTip(RadControl associatedControl, string toolTipText, string toolTipTitle, int toolTipX, int toolTipY, int toolTipDuration, bool enableToolTipShadow)
Parameters
RadControl
associatedControl
The RadControl to display the tooltip on. |
System.String
toolTipText
The text content of the tooltip. |
System.String
toolTipTitle
The title text of the tooltip. |
System.Int32
toolTipX
The X coordinate position for the tooltip. |
System.Int32
toolTipY
The Y coordinate position for the tooltip. |
System.Int32
toolTipDuration
The duration in milliseconds to display the tooltip. |
System.Boolean
enableToolTipShadow
true to enable shadow effect on the tooltip; otherwise false. |
Validate(RadEditorControl)
Validates the specified editor control against all associated validation rules.
Declaration
public bool Validate(RadEditorControl control)
Parameters
RadEditorControl
control
A RadEditorControl or descendant that represents the editor to be validated. |
Returns
System.Boolean
true if the editor has been successfully validated against all rules; otherwise false. |
Events
ControlValidation
Occurs before a RadEditorControl is being validated, allowing custom validation logic and error handling.
Declaration
public event RadValidationEventHandler ControlValidation
Event Type
RadValidationEventHandler
|
ValidationModeChanged
Occurs when the ValidationMode property has changed, notifying subscribers of the validation timing change.
Declaration
public event EventHandler ValidationModeChanged
Event Type
System.EventHandler
|