Skip to main content
All docs
V24.1
.NET 6.0+

How to: Access the Grid Component in a List View

  • 3 minutes to read

This article explains how to access properties of a grid component displayed in a List View.

You can use this technique with any List Editor control in ASP.NET Core Blazor, Windows Forms, or ASP.NET Web Forms applications.

Step-by-Step Instructions

  1. In Solution Explorer, navigate to:
    • A platform-specific project in a .NET ASP.NET Core Blazor or Windows Forms application.
    • A platform-specific module project in a .NET Framework ASP.NET Web Forms or Windows Forms application.
  2. Add a View Controller to the Controllers folder.
  3. Inherit the controller from the ObjectViewController<ViewType, ObjectType> class and override the OnViewControlsCreated method as demonstrated in the following code example:

     using DevExpress.Blazor;
     using DevExpress.ExpressApp;
     using DevExpress.ExpressApp.Blazor.Editors;
     using MainDemo.Module.BusinessObjects;
     using YourApplicationName.Module.BusinessObjects;
    
     namespace YourApplicationName.Blazor.Server.Controllers;
    
     public class EmployeeListViewController : ObjectViewController<ListView, Employee> {
         protected override void OnViewControlsCreated() {
             base.OnViewControlsCreated();
             if(View.Editor is DxGridListEditor editor) {
                 editor.GridModel.ColumnResizeMode = GridColumnResizeMode.ColumnsContainer;
    
                 foreach(var columnModel in editor.GridDataColumnModels) {
                     if(columnModel.FieldName == "Department.Title") {
                         columnModel.FilterMenuButtonDisplayMode = GridFilterMenuButtonDisplayMode.Never;
                     }
                     columnModel.MinWidth = 50;
                 }
             }
         }
     }
    

Platform-Specific Events for Control Customization

In Windows Forms or ASP.NET Web Forms applications, a View Item control or a List Editor control may not be ready for customization immediately after creation. If the technique described in this topic does not have the desired effect, handle platform-specific events listed below.

Windows Forms:

The Control object’s HandleCreated, VisibleChanged, or ParentChanged event.

You can also handle Load or any similar event if the current control type exposes it.

ASP.NET Web Forms:

The Control object’s Load or Init server-side event.

Alternatively, you may need to handle the WebWindow.PagePreRender event. Use the CurrentRequestWindow static property to get the current WebWindow object.

If your application also requires customization on the client side, refer to the following topic for additional information: Client-Side Functionality.

ASP.NET Core Blazor
XAF ASP.NET Core Blazor apps do no need specialized events to customize their underlying controls. However, you must use an EventCallback-based approach instead of handling regular C# events for underlying Blazor UI controls. For more information, refer to the Handle Component Events section.

Contact our Support Center if you need help.

See Also