LookUpEditBase.ProcessNewValue Event

Allows a new value entered into the edit box, to be added to the items source.

Namespace: DevExpress.Xpf.Editors

Assembly: DevExpress.Xpf.Core.v19.2.dll

Declaration

public event ProcessNewValueEventHandler ProcessNewValue
Public Event ProcessNewValue As ProcessNewValueEventHandler

Event Data

The ProcessNewValue event's handler receives an argument of the ProcessNewValueEventArgs type. The following properties provide information specific to this event:

Property Description
DisplayText Gets the text entered by an end-user within the editor's edit box.
Handled Gets or sets a value that indicates the present state of the event handling for a routed event as it travels the route. Inherited from RoutedEventArgs.
OriginalSource Gets the original reporting source as determined by pure hit testing, before any possible Source adjustment by a parent class. Inherited from RoutedEventArgs.
PostponedValidation Gets or sets whether to postpone edit value validation.
RoutedEvent Gets or sets the RoutedEvent associated with this RoutedEventArgs instance. Inherited from RoutedEventArgs.
Source Gets or sets a reference to the object that raised the event. Inherited from RoutedEventArgs.

Remarks

If the editor cannot find an item that matches the text entered by an end-user within the edit box (ProcessNewValueEventArgs.DisplayText), the ProcessNewValue event occurs. Handle this event to manually validate a new value, and if required, add the corresponding record to a data source.

The ProcessNewValue event is raised after a new value has been validated, allowing you to add this value to the items source. By default, the validation occurs while typing within the editor's text box (see BaseEdit.ValidateOnTextInput). As a result, the ProcessNewValue event is fired each time a user presses a keyboard key.

The ProcessNewValue event occurs if an end-user presses the Enter key (the BaseEdit.ValidateOnEnterKeyPressed property should be set to true) or moves focus to another control.

If you add a new record, set the event parameter's Handled property to true.

NOTE

If you want to show a floating container allowing an end-user to specify other values for a new record, set the event parameter's ProcessNewValueEventArgs.PostponedValidation property to true. In this instance, a new value will be validated after a floating container is closed.

Examples

This example shows how to manually initialize a new value and add it to a data source.

Update: Starting with version 13.1 of DevExpress controls, you can use the DevExpress MVVM Framework to accomplish this task. It is necessary to create a command in the view model (for instance, the ShowProductFormCommand command) and bind it with the LookUpEditBase.ProcessNewValue event via the trigger. This would allow you to display the dialog (UserControl1.xaml file) for editing new source items in the LookUpEdit control when this even is raised. Then, you can implement custom logic in the OnShowProductFormCommandExecute (ProductList.cs file) method to process values in this dialog. Please review our blogs to find additional information about DevExpress MVVM Framework:

<Application x:Class="HowToCreateLookUpEdit.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:local="clr-namespace:HowToCreateLookUpEdit"
             xmlns:viewmodel="clr-namespace:HowToCreateLookUpEdit.ViewModel"
             StartupUri="MainWindow.xaml">
    <Application.Resources>
        <viewmodel:StringToIntConverter x:Key="converter" />
    </Application.Resources>
</Application>
See Also