Validation action

Namespace: Dapfor.Net.Ui
Assembly: Dapfor.Net (in Dapfor.Net.dll) Version: 2.10.3.24917 (2.10.3.24917)

Syntax

C#
public enum ValidateCellAction
Visual Basic
Public Enumeration ValidateCellAction
Visual C++
public enum class ValidateCellAction
F#
type ValidateCellAction

Field Value

Type:
The action.

Members

Member nameValueDescription
ApplyValue0 Records a new value to the data object. If an exception is thrown during recording, Grid.ValidateCell event is generated one more time with clarifying information.
CancelValue1 Informs the grid that the new value doesn't have to be recorded to a data object. It is also possible to set a user-friendly message that will be displayed as a tooltip. If grid navigation is turned on (tab, tab+shift), the grid starts editing a new cell.
RestartEdit2 Informs the grid that it has to restart editing current cell value.
StopEdit3 The new value is not recorded to the data object and the editing process is stopped. Unlike CancelValue, navigation between edited grid cells is ignored.

Remarks

To validate edited data the programmer has to subscribe to Grid.ValidateCell event that transmits data of the edited cell, new value that shall be transferred to business logic object, message that has to be displayed after editing. In this event it is possible also to set an action instructing the grid of what has to be done after editing.

Examples

 Copy imageCopy
//Add handler to validate cells
grid.ValidateCell += OnValidateCell;

//Validation handler
private void OnValidateCell(object sender, Ui.ValidateCellEventArgs e)
{
    //Default validation logic:
    bool valid = e.Exception == null && string.IsNullOrEmpty(e.ErrorText);

    //Add your validation logic here. 
    //valid = ... 

    if (!valid)
    {
        e.Action = ValidateCellAction.StopEdit;
        e.ErrorText = "Please enter a valid value.";
    }
}

See Also