Skip to main content
A newer version of this page is available. .
.NET Framework 4.5.2+

ListViewProcessCurrentObjectController.CustomProcessSelectedItem Event

Occurs before the ListViewShowObject Action (ListViewProcessCurrentObjectController.ProcessCurrentObjectAction) is executed in List Views with MasterDetailMode set to ListViewOnly.

Namespace: DevExpress.ExpressApp.SystemModule

Assembly: DevExpress.ExpressApp.v21.2.dll

NuGet Package: DevExpress.ExpressApp

Declaration

public event EventHandler<CustomProcessListViewSelectedItemEventArgs> CustomProcessSelectedItem

Event Data

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

Remarks

When a 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. The CustomProcessSelectedItem event allows you to execute a custom Action instead of the ListViewShowObject Action in specific List Views. For example, the WinForms ReportsController invokes the Report Designer, and the ASP.NET Web Forms ReportsController invokes the Report Viewer instead of a Detail View. When you handle the CustomProcessSelectedItem event, set the CustomProcessListViewSelectedItemEventArgs.Handled parameter to true to prevent execution of the default Action after your Action execution. To access the currently selected object, use the CustomProcessListViewSelectedItemEventArgs.InnerArgs.CurrentObject parameter.

The example below demonstrates the Controller that handles the CustomProcessSelectedItem event to show a custom Detail View:

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

  • When a List View’s MasterDetailMode is set to ListAndDetailView, handle the CreateCustomCurrentObjectDetailView event to specify or customize the Detail View created after the List View’s current object is changed.
  • The WebApplication.OptimizationSettings.AllowFastProcessListViewRecordActions option can affect the CustomProcessSelectedItem event handling. Disable this option as described in the following KB article if you encounter any issues when you process selected items in this event handler (for example, issues with default UI element rendering or behavior): Faster rendering and other performance optimizations for popular Web UI scenarios in XAF.

You can find more examples in the following help topic: How to: Replace a List View’s Default Action.

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

See Also