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.v25.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 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, while the ASP.NET Core Blazor 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. 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
MasterDetailModeis set toListAndDetailView, handle the CreateCustomCurrentObjectDetailView event to specify or customize the Detail View created after the List View’s current object is changed.
For more examples, refer to the following 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.