Skip to main content
All docs
V23.2
.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 6 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.ExpressApp;
    using DevExpress.ExpressApp.Blazor.Editors;
    
    namespace YourApplicationName.Blazor.Server.Controllers {
        public class ColumnResizeModeViewController : ViewController<ListView> {
            protected override void OnViewControlsCreated() {
                base.OnViewControlsCreated();
                if (View.Editor is DxGridListEditor gridListEditor) {
                    gridListEditor.GridModel.ColumnResizeMode =
                        DevExpress.Blazor.GridColumnResizeMode.ColumnsContainer;
                }
            }
        }
    }
    

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