Data Validation in PropertyGrid
KetticPropertyGrid control for Windows Forms contains a variety of built-in editors used to edit different data types. All the built in editors can be replaced by custom editors. This PropertyGrid control for Windows Forms allows the users easily to validate data before the data is committed. The data validation process will re quire the ValidateProperty event and the data editing mode will be enabled by disabling the read-only mode of the PropertyGrid items.
Handle PropertyGrid Data Validating Event of in C#.NET
KetticPropertyGrid control for Windows Forms application offers the ValidateProperty event for the users to perform the data validating process. This event for data validation will be fired when we change the current PropertyGrid item or when the PropertyGrid item loses its input focus. To cancel this data validation event, we should input a valid editor value or cancel the data validation process. Data Validation Events for PropertyGrid
To handle the data validation, we can use the C# events as below,
C# code for Data Validating in PropertyGrid
In the following example, we are going to demonstrate how to validating data for a PropertyGrid item using C# code. The data validation is performed on a string property, which forbids empty string input. The ValidateProperty event will check if the input string is empty. When the data value validation fails, the error indicator will appear and this ValidateProperty event will be canceled. When the data value is valid in Edited event, the error indicator will not appear. The C# code snippet gives more details.
| ![]() UI Controlsfor Windows Forms .NET WinForms UI Overview.NET WinForms UI Features.NET WinForms UI GuideC# WinForms UI DesignVB.NET WinForms UI DesignWinForms UI Controls WinForms Buttons UI Control WinForms Calendar UI ControlWinForms Carousel UI ControlWinForms Chart UI ControlWinForms Clock UI ControlCommandBar UI ControlWinForms Dock UI ControlDesktop Alert UI ControlDropDown List UI ControlWinForms Editor UI ControlForms and Dialogs UI ControlWinForms GridView UI ControlWinForms ListView UI ControlWinForms Menu UI ControlWinForms ComboBox UI ControlWinForms PageView UI ControlPanels and Labels UI ControlWinForms Panorama UI ControlWinForms PDFViewer UI ControlWinForms Property Grid UI ControlGet Started in C#Property Grid - AttributeAdd Custom PropertiesBinding to Multiple ObjectsProperty Grid - CustomizationProperty Grid - LocalizationProperty Grid - EditorsC# API & EventsValidationCustomizing Editor BehaviorHandle EventsProperty Grid - FeaturesFeatures - filteringFeatures - GroupingCustom GroupingFeatures - SortingFeatures - Help BarFeatures - Tool BarWinForms Ribbon UI ControlWinForms PivotGrid UI ControlWinForms RichTextBox UI ControlWinForms Rotator UI ControlWinForms Scheduler UI ControlWinForms Shortcuts UI ControlWinForms SpellChecker UI ControlWinForms Track & Status UI ControlWinForms TreeView UI ControlWinForms Wizard UI ControlWinForms Test UI ControlWinForms Theme UI Control |