Creating Editors the Simple Way With GenericEditorBase

The far more simpler way for creating most editors is to inherit from the Connect4.SQLDesigner.WinUI.Editors.GenericEditorBase which is a user control with the interface fully implemented.

 

All you need to do to create an editor via this method is to inherit the GenericEditorBase and override one or two properties depending on what kind of editor you wish to create.

 

If you wish to create a list editor (that is an editor that provides values for SQL syntax like IN) then you will need to override the ValueArray property. In set part of the property you will receive a string array with the values that are already held by the condition object. In the get part of the property you will have to return an array of values.

 

If you only deal with one value at a time then override the Value property and have it set/return the value as a string.

 

Note: If you do not override the ValueArray property and the editor is used in list mode or if you don't override the Value property and it is used in a single entry mode then a NotSupportedException will be thrown.

 

 

Validation

 

Validation is taken care of automatically by the base editor, however if you want to perform more complex validation then you can override the DoValidation method returning true if successful, see below for more information about overriding DoValidation.

 

For list editors

If the array you return is in anyway different to the one that supplied to start with (including number and order of elements) then all the elements in the array will be validated and then assigned to the condition object if it is valid.

 

For single values

If the value is different in anyway then it will run through the validation and be assigned to the condition object if it is valid.

 

Overriding DoValidation

If you chose to override DoValidation then there are a few things you will need to take into account.