Occurs when a value should be validated while cell editing.

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

Syntax

C#
public event EventHandler<ValidateCellEventArgs> ValidateCell
Visual Basic
Public Event ValidateCell As EventHandler(Of ValidateCellEventArgs)
Visual C++
public:
 event EventHandler<ValidateCellEventArgs^>^ ValidateCell {
	void add (EventHandler<ValidateCellEventArgs^>^ value);
	void remove (EventHandler<ValidateCellEventArgs^>^ value);
}
F#
member ValidateCell : IEvent<EventHandler<ValidateCellEventArgs>,
    ValidateCellEventArgs>

Value

Type: System..::..EventHandler<(Of <(<'ValidateCellEventArgs>)>)>

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