Skip to main content
.NET 6.0+

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.v24.1.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 clicks an object in the current List View (double click in Windows Forms) or selects an object and presses Enter, XAF executes the ListViewShowObject Action. This Action invokes a Detail View for the selected object. Handle the CustomProcessSelectedItem event to execute a custom Action instead of the ListViewShowObject Action in specific List Views. For example, the Windows Forms ReportsController invokes the Report Designer, and both the ASP.NET Web Forms ReportsController and the ASP.NET Core Blazor ReportsController invoke 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. To access the currently selected object, use the CustomProcessListViewSelectedItemEventArgs.InnerArgs.CurrentObject parameter.

The example below demonstrates a 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 if you encounter any issues when you process selected items in this event handler (for example, issues with default UI element rendering or behavior). For more information, refer to the following topic: 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 double-click processing in a GridListEditor, set the GridListEditor.ProcessSelectedItemByDoubleClick property to false.

See Also