windowsforms-devexpress-dot-xtraeditors-dot-baseedit-1233717e.md
Fires when the editor’s value is about to change.
Namespace : DevExpress.XtraEditors
Assembly : DevExpress.XtraEditors.v25.2.dll
NuGet Package : DevExpress.Win.Navigation
[DXCategory("Events")]
public event ChangingEventHandler EditValueChanging
<DXCategory("Events")>
Public Event EditValueChanging As ChangingEventHandler
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.MaskSettings). |
| OldValue | Gets the editor’s value. |
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;
}
'INSTANT VB NOTE: This code snippet uses implicit typing. You will need to set 'Option Infer On' in the VB file or set 'Option Infer' at the project level.
Private textEdit1.EditValueChanging += AddressOf TextEdit1_EditValueChanging
Private Sub TextEdit1_EditValueChanging(ByVal sender As Object, ByVal e As DevExpress.XtraEditors.Controls.ChangingEventArgs)
Dim value = e.NewValue.ToString()
Dim i As Integer = 0
If Not Integer.TryParse(value, i) Then
e.Cancel = True
End If
End Sub
See Also