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
ViewNameproperty for theGridViewdescendant. This property should return a unique View name. - Register the
GridViewdescendant for design-time use:- Create a
GridInfoRegistratorclass descendant. ItsViewNameproperty must return the same value as your View'sViewNameproperty. - Override the
RegisterAvailableViewsCoremethod in yourGridControldescendant. - If you want the custom
GridControlto create an instance of theGridViewdescendant on the grid's initialization, override theGridControl.CreateDefaultViewmethod. - Mark your grid control with the
[ToolboxItem(true)]attribute.
- Create a
- Rebuild the solution to display the
MyGridControlin the Visual Studio Toolbox. - Locate MyGridControl` in the Visual Studio Toolbox, drag and drop it on a Form.
- 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)