Back to Devexpress

ListEditor Class

expressappframework-devexpress-dot-expressapp-dot-editors-a9af1954.md

latest11.9 KB
Original Source

ListEditor Class

The base class for List Editors.

Namespace : DevExpress.ExpressApp.Editors

Assembly : DevExpress.ExpressApp.v25.2.dll

NuGet Package : DevExpress.ExpressApp

Declaration

csharp
public abstract class ListEditor :
    IDisposable,
    IProtectedContentEditor,
    IServiceProviderClient
vb
Public MustInherit Class ListEditor
    Implements IDisposable,
               IProtectedContentEditor,
               IServiceProviderClient

The following members return ListEditor objects:

Remarks

List Views are visualized by means of List Editors. A List Editor has a control that is used to display an object collection supplied by a List View. The List Editor handles binding of its control and supports interaction between the List View and the control.

The List Editor that represents a specific List View can be accessed using the ListView.Editor property. The following code snippet demonstrates how to do this by handling the Controller.Activated and ViewController.ViewControlsCreated events:

csharp
using System;
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Editors;
using DevExpress.XtraGrid;
//...
public partial class MyController : ViewController {
    public MyController() {
        TargetViewType = ViewType.ListView;
        Activated += MyController_Activated;
        ViewControlsCreated += MyController_ViewControlsCreated;
    }
    private void MyController_Activated(object sender, EventArgs e) {
        ListEditor listEditor = ((ListView)View).Editor;
        //Do what is required with the List Editor            
    }
    void MyController_ViewControlsCreated(object sender, EventArgs e) {
        ListEditor listEditor = ((ListView)View).Editor;
        GridControl gridControl = (GridControl)listEditor.Control;
        //Do what is required with the List Editor's control
    }
}

To display List Views XAF uses GridListEditor in WinForms applications and DxGridListEditor in Blazor applications.

You can use the ListEditor class and its descendant to implement custom List Editors. When deriving from the ListEditor class, you can override the following protected members that are not described in the documentation:

MemberDescription
AssignDataSourceToControlCalled in the CreateControls() method and the DataSource property setter.
This method is abstract. Override it to assign the current List Editor’s data source to the control.
CreateControlsCoreCalled in the CreateControls() method.
This method is abstract. Override it to instantiate the List Editor’s control.
OnAllowEditChangedCalled in the AllowEdit property setter.
Raises the AllowEditChanged event. Call this method after the List Editor’s edit mode has changed.
OnFocusedObjectChangingRaises the FocusedObjectChanging event. Call this method before the focused object is changed in the List Editor’s control.
OnFocusedObjectChangedRaises the FocusedObjectChanged event. Call this method after the focused object is changed in the List Editor’s control.
OnNewObjectAddingRaises the NewObjectAdding event. Call this method before a new object is created in the List Editor’s control.
OnNewObjectCanceledRaises the NewObjectCanceled event. Call this method after creation of a new object is canceled in the List Editor’s control.
OnNewObjectCreatedRaises the NewObjectCreated event. Call this method after a new object is created in the List Editor’s control.
OnProcessSelectedItemRaises the ProcessSelectedItem event. Call this method when an object is selected in the List Editor’s control and an end-user presses Enter or double-clicks the object.
OnSelectionChangedRaises the SelectionChanged event. Call this method after the selection is changed in the List Editor’s control.
OnSelectionTypeChangedRaises the SelectionTypeChanged event. Call this method after the List Editor’s supported selection type is changed.

Typical implementation of the ListEditor class’ descendants comprises the following steps:

  1. Override the CreateControlsCore method. Create and configure an instance of the control that will represent a List View in a UI. Handle the control’s events to call the following methods:
  • OnProcessSelectedItem
  • OnSelectionChanged
  • OnFocusedObjectChanging
  • OnFocusedObjectChanged
  • OnNewObjectAdding
  • OnNewObjectCanceled
  • OnNewObjectCreated
  1. Override the AssignDataSourceToControl method. Assign the List Editor’s data source to its control.
  2. Override the Refresh() method. Refresh data in the List Editor’s control.
  3. Override the RequiredProperties property. Return business class’ property names that are used by the List Editor when displaying objects. These properties are treated as displayable if a List View’s data source is derived from the XPBaseCollection.
  4. Override the SelectionType property. Return the selection type supported by the List Editor’s control.
  5. Override the GetSelectedObjects() method. Return a list of the selected objects.
  6. Override the FocusedObject method. Get and set the control’s focused object.
  7. If the custom List Editor does not support List View data access mode, override the SupportsDataAccessMode(CollectionSourceDataAccessMode) property. It is also recommended that you implement a custom generator updater to disable unsupported modes for List Views visualized by the custom List Editor.
  8. Modify the constructor to instantiate the control that will represent the List Editor’s pop-up menu. This control must implement the IDXPopupMenuHolder interface to support XAF architecture. Override the ContextMenuTemplate property to return the created instance of the control.
  9. Mark the custom List Editor with the ListEditorAttribute.

Note

For an example of a List Editor derived from the ListEditor class, refer to the following topics:

Inheritance

Show 18 items

Object ListEditor DxChartListEditor

ChartListEditorBase

ColumnsListEditor

PivotGridListEditorBase

SchedulerListEditorBase

DxGridListEditorBase

DxTreeListEditor

PivotGridListEditor

SchedulerListEditor

CategorizedListEditor

TreeListEditor

DxGridListEditor

WinColumnsListEditor

SchedulerListEditor

GridListEditor

ChartListEditor

See Also

ListEditor Members

List Editors

ListEditorAttribute

IComplexListEditor

DevExpress.ExpressApp.Editors Namespace