Skip to main content
.NET Framework 4.6.2+

ListEditor Class

Represents the base class for List Editors.

Namespace: DevExpress.ExpressApp.Editors

Assembly: DevExpress.ExpressApp.v24.2.dll

NuGet Package: DevExpress.ExpressApp

Declaration

public abstract class ListEditor :
    IDisposable,
    IProtectedContentEditor,
    IServiceProviderClient

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:

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
    }
}

By default, XAF uses two ListEditor class’ descendants to visualize List Views: the GridListEditor is used in WinForms applications, and the ASPxGridListEditor is used in ASP.NET Web Forms applications.

The base class for all List Editor types is the ListEditor. This class and its descendants can be used to implement custom List Editors. When deriving from the ListEditor class, the following protected members that are not described in the documentation can be overridden:

Member When it is called Description
AssignDataSourceToControl Called in the ListEditor.CreateControls method and the ListEditor.DataSource property setter. This method is abstract. Override it to assign the current List Editor’s data source to the control.
CreateControlsCore Called in the ListEditor.CreateControls method. This method is abstract. Override it to instantiate the List Editor’s control.
OnAllowEditChanged Called in the ListEditor.AllowEdit property setter. Raises the ListEditor.AllowEditChanged event. Call this method after the List Editor’s edit mode has changed.
OnFocusedObjectChanging This method is not called in the ListEditor class. Raises the ListEditor.FocusedObjectChanging event. Call this method before the focused object is changed in the List Editor’s control.
OnFocusedObjectChanged This method is not called in the ListEditor class. Raises the ListEditor.FocusedObjectChanged event. Call this method after the focused object is changed in the List Editor’s control.
OnNewObjectAdding This method is not called in the ListEditor class. Raises the ListEditor.NewObjectAdding event. Call this method before a new object is created in the List Editor’s control.
OnNewObjectCanceled This method is not called in the ListEditor class. Raises the ListEditor.NewObjectCanceled event. Call this method after creation of a new object is canceled in the List Editor’s control.
OnNewObjectCreated This method is not called in the ListEditor class. Raises the ListEditor.NewObjectCreated event. Call this method after a new object is created in the List Editor’s control.
OnProcessSelectedItem This method is not called in the ListEditor class. Raises the ListEditor.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.
OnSelectionChanged This method is not called in the ListEditor class. Raises the ListEditor.SelectionChanged event. Call this method after the selection is changed in the List Editor’s control.
OnSelectionTypeChanged This method is not called in the ListEditor class. Raises the ListEditor.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

  2. Override the AssignDataSourceToControl method. Assign the List Editor’s data source to its control.
  3. Override the ListEditor.Refresh method. Refresh data in the List Editor’s control.
  4. Override the ListEditor.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.
  5. Override the ListEditor.SelectionType property. Return the selection type supported by the List Editor’s control.
  6. Override the ListEditor.GetSelectedObjects method. Return a list of the selected objects.
  7. Override the ListEditor.FocusedObject method. Get and set the control’s focused object.
  8. If the custom List Editor does not support List View data access mode, override the ListEditor.SupportsDataAccessMode 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.
  9. 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 ListEditor.ContextMenuTemplate property to return the created instance of the control.
  10. Mark the custom List Editor with the ListEditorAttribute.

Note

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

See Also