Back to Devexpress

ChangingEventHandler Delegate

windowsforms-devexpress-dot-xtraeditors-dot-controls-87d62595.md

latest2.5 KB
Original Source

ChangingEventHandler Delegate

Represents a method that will handle the RepositoryItem.EditValueChanging event.

Namespace : DevExpress.XtraEditors.Controls

Assembly : DevExpress.XtraEditors.v25.2.dll

NuGet Package : DevExpress.Win.Navigation

Declaration

csharp
public delegate void ChangingEventHandler(
    object sender,
    ChangingEventArgs e
);
vb
Public Delegate Sub ChangingEventHandler(
    sender As Object,
    e As ChangingEventArgs
)

Parameters

NameTypeDescription
senderObject

The event sender (typically the BaseEdit descendant).

| | e | ChangingEventArgs |

A ChangingEventArgs object containing data related to the event.

|

Remarks

When creating a ChangingEventHandler delegate, you identify the method that will handle the corresponding event. To associate an event with your event handler, add a delegate instance to this event. The event handler is called whenever the event occurs unless you remove the delegate.

The code sample below handles the TextEdit’s EditValueChanged event to accept only numeric values:

csharp
textEdit1.EditValueChanging += TextEdit1_EditValueChanging;

void TextEdit1_EditValueChanging(object sender, DevExpress.XtraEditors.Controls.ChangingEventArgs e) {
    int i = 0;
    if (!int.TryParse(e.NewValue.ToString(), out i))
        e.Cancel = true;
}
vb
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

DevExpress.XtraEditors.Controls Namespace