DevExpress-Examples / winforms-grid-create-gridview-descendant

Create a GridView descendant and register it for design-time use.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

WinForms Data Grid - How to create a GridView descendant and use it at design time

In v16.1+, you can use the Custom Data Grid template shipped as part of the DevExpress Template Gallery to create a GridView descendant with pre-built infrastructure classes.

This example demonstrates how to create a custom view (a GridView descendant) from scratch. The descendant View allows users to delete records by pressing the Delete key. Open the solution and build the project before opening Form1 in the Visual Studio designer.

How it Works - Descendant View Concept

  1. Create descendants of the following classes and implement custom functionality:
    • GridView - The component that exposes customization settings and references all infrastructure classes.
    • GridControl - The UI control that you place on the form. This is a container for the View.
    • GridInfoRegistrator - Contains the View's registration information.
    • GridHandler - Processes mouse and keyboard actions.
    • GridViewInfo - Calculates display information used to draw View elements.
    • GridViewPrintInfo - Calculates the information required to print the View.
  2. Override the ViewName property for the GridView descendant. This property should return a unique View name.
  3. Register the GridView descendant for design-time use:
    • Create a GridInfoRegistrator class descendant. Its ViewName property must return the same value as your View's ViewName property.
    • Override the RegisterAvailableViewsCore method in your GridControl descendant.
    • If you want the custom GridControl to create an instance of the GridView descendant on the grid's initialization, override the GridControl.CreateDefaultView method.
    • Mark your grid control with the [ToolboxItem(true)] attribute and rebuild the solution to display the custom GridControl in the Visual Studio Toolbox.

Files to Review

See Also

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)

About

Create a GridView descendant and register it for design-time use.

License:Other


Languages

Language:Visual Basic .NET 54.6%Language:C# 45.4%