BaseEdit.EditValueChanging Event
Fires when the editor’s value is about to change.
Namespace: DevExpress.XtraEditors
Assembly: DevExpress.XtraEditors.v24.2.dll
Declaration
Event Data
The EditValueChanging event's data class is ChangingEventArgs. The following properties provide information specific to this event:
Property | Description |
---|---|
Cancel | Gets or sets a value indicating whether the event should be canceled. Inherited from CancelEventArgs. |
IsBoundUpdatingEditValue | For internal use. |
IsTextChanging | For internal use. |
ModifiedByUser | Gets whether a user changed the value. |
NewValue | Gets or sets the value which is about to be assigned to the editor. Setting the NewValue property is not supported if the editor uses masked input (RepositoryItemTextEdit.Mask). |
OldValue | Gets the editor’s value. |
Remarks
The editor’s EditValueChanging event is equivalent to the RepositoryItem.EditValueChanging event, available from the BaseEdit.Properties object.
Note
Do not display modal dialogs or move focus within the EditValueChanging event, as this can lead to the loss of the current value.
Refer to the RepositoryItem.EditValueChanging event description for additional information.
The code sample below illustrates how to accept only numeric values in a text edit.
textEdit1.EditValueChanging += TextEdit1_EditValueChanging;
private void TextEdit1_EditValueChanging(object sender, DevExpress.XtraEditors.Controls.ChangingEventArgs e)
{
int i = 0;
if (!int.TryParse(e.NewValue.ToString(), out i))
e.Cancel = true;
}