Gets or sets the 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 ValidateCellAction Action { get; set; }
Visual Basic
Public Property Action As ValidateCellAction
	Get
	Set
Visual C++
public:
property ValidateCellAction Action {
	ValidateCellAction get ();
	void set (ValidateCellAction value);
}
F#
member Action : ValidateCellAction with get, set

Property Value

Type: ValidateCellAction
The action.

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.

There are 4 possible actions:

  • ApplyValue - 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.
  • CancelValue - 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.
  • RestartEdit - Informs the grid that it has to restart editing current cell value.
  • StopEdit - 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.

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