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.
- 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.
- Override the
ViewName
property for theGridView
descendant. This property should return a unique View name. - Register the
GridView
descendant for design-time use:- Create a
GridInfoRegistrator
class descendant. ItsViewName
property must return the same value as your View'sViewName
property. - Override the
RegisterAvailableViewsCore
method in yourGridControl
descendant. - If you want the custom
GridControl
to create an instance of theGridView
descendant on the grid's initialization, override theGridControl.CreateDefaultView
method. - Mark your grid control with the
[ToolboxItem(true)]
attribute and rebuild the solution to display the customGridControl
in the Visual Studio Toolbox.
- Create a
- Customer.cs (VB: Customer.vb)
- Form1.cs (VB: Form1.vb)
- MyGridControl.cs (VB: MyGridControl.vb)
- MyGridHandler.cs (VB: MyGridHandler.vb)
- MyGridRegistration.cs (VB: MyGridRegistration.vb)
- MyGridView.cs (VB: MyGridViewInfo.vb)
- MyGridViewInfo.cs (VB: MyGridViewInfo.vb)
- Program.cs (VB: Program.vb)
- Create GridView descendants
- DevExpress WinForms Troubleshooting - Grid Control
- How to create a WinExplorerView descendant class and register it for design-time use
- How to create a LayoutView descendant class and register it for design-time use
- How to create a CardView descendant class and register it for design-time use
- How to create an AdvBandedGridView descendant class and register it for design-time use
- How to create a BandedGridView descendant class and register it for design-time use
- How to create a TileView descendant class and register it for design-time use
(you will be redirected to DevExpress.com to submit your response)