Skip to main content
A newer version of this page is available. .

ListViewProcessCurrentObjectController.CustomProcessSelectedItem Event

Occurs when the ListViewShowObject Action (ListViewProcessCurrentObjectController.ProcessCurrentObjectAction) is about to be executed.

Namespace: DevExpress.ExpressApp.SystemModule

Assembly: DevExpress.ExpressApp.v19.1.dll

Declaration

public event EventHandler<CustomProcessListViewSelectedItemEventArgs> CustomProcessSelectedItem

Event Data

The CustomProcessSelectedItem event's data class is DevExpress.ExpressApp.SystemModule.CustomProcessListViewSelectedItemEventArgs.

Remarks

When an end-user double-clicks an object in the current List View, or presses ENTER for a selected object, the ListViewShowObject Action is executed. This Action invokes a Detail View for the selected object. You may need to execute a custom Action instead of the ListViewShowObject Action in a certain List View. For instance, the Windows Forms ReportsController invokes the Report Designer, and the ASP.NET ReportsController invokes the Report Viewer for the selected object. To replace the default ListViewShowObject Action with a custom one, handle the CustomProcessSelectedItem event. Set the handler’s CustomProcessListViewSelectedItemEventArgs.Handled parameter to true to prevent execution of the default Action after your Action has been executed. To access the object currently selected in the List View, use the handler’s CustomProcessListViewSelectedItemEventArgs.InnerArgs.CurrentObject parameter.

Code snippet below demonstrates the Controller that shows a custom Detail View using the CustomProcessSelectedItem event.

using DevExpress.ExpressApp;
using DevExpress.ExpressApp.SystemModule;
// ...
public class ProcessContactListViewRowController : ViewController {
    public ProcessContactListViewRowController() {
        TargetViewId = "Contact_ListView";
    }
    protected override void OnActivated() {
        base.OnActivated();
        ListViewProcessCurrentObjectController listProcessController = Frame.GetController<ListViewProcessCurrentObjectController>();
        if(listProcessController != null)
            listProcessController.CustomProcessSelectedItem += ProcessContactListViewRowController_CustomProcessSelectedItem;        
    }
    void ProcessContactListViewRowController_CustomProcessSelectedItem(
        object sender, CustomProcessListViewSelectedItemEventArgs e) {
        Contact currentContact = (Contact)e.InnerArgs.CurrentObject;
        if (currentContact.Position != null && currentContact.Position.Title == "Manager") {
            IObjectSpace objectSpace = Application.CreateObjectSpace(currentContact.GetType());
            e.InnerArgs.ShowViewParameters.CreatedView = Application.CreateDetailView(objectSpace, "Contact_DetailView_Manager", true, objectSpace.GetObject(currentContact));
            e.Handled = true;
        }
    }
    protected override void OnDeactivated() {
        base.OnDeactivated();
        Frame.GetController<ListViewProcessCurrentObjectController>().CustomProcessSelectedItem -= ProcessContactListViewRowController_CustomProcessSelectedItem;
    }
}

Note

The WebApplication.OptimizationSettings.AllowFastProcessListViewRecordActions option can influence the CustomProcessSelectedItem event. Disable this option as described in the Faster rendering and other performance optimizations for popular Web UI scenarios in XAF KB article, if you face any difficulty when custom processing selected items is implemented in this event handler (e.g., difficulty with the default UI elements rendering or behavior).

More examples of handling the CustomProcessSelectedItem event are provided in the How to: Replace a List View’s Default Action topic.

To completely disable the GridListEditor‘s management of double clicks, set the GridListEditor.ProcessSelectedItemByDoubleClick property to false.

The following code snippets (auto-collected from DevExpress Examples) contain references to the CustomProcessSelectedItem event.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also