KB Article A527
Visible to All Users

How to configure a detail grid view (design~ / runtime)

Description:
How do I customize the grid detailed view?

Answer:
You can do this at design time as well as at runtime.
AT DESIGN TIME
When an XtraGrid control is placed on a form, the Level Designer is displayed in the bottom right corner of the control. Initially, the level designer provides access to the automatically created View that represents the grid's main View (GridControl.MainView):

If the grid is bound to a data source that contains master-detail relationships, the information about master-detail relationships can be retrieved from the bound data source by clicking the Retrieve Details button. As a result, new levels, whose names match the name of the relationship to which the level corresponds, are created. A level in XtraGrid is simply an association of a master-detail relationship. The View used to represent this relationship (the level name) should match the name of the master-detail relationship. Select the required view in order to customize it - show/hide columns, define grouping, sorting, and summaries, apply styles, etc.
If it is impossible to retrieve the data structure, you can create and customize all levels and views manually using the Level Designer:

  1. Create a new level and assign a view to it. When adding a new level node to the GridLevelNode.Nodes collection, its GridLevelNode.RelationName should match the relationship's name.
  2. Create required columns. The column's FieldName should match the source's field name. See the training video from DevExpress StartHere. You can find it in Visual Studio: DevExpress --> StartHere --> WinForms --> DataGrid --> MasterDetailRelationships
    AT RUNTIME
    To customize each detail view, handle the GridControl.ViewRegistered event in order to perform all the necessary customizations. Use the e.View parameter to assess the currently processed view. Or, handle the GridView.MasterRowExpanded event. Obtain the detail view using the GridView.GetDetailedView method. Review the A2158 to learn how to obtain the detailed view's properties. See the GridRunTimeUsing tutorial shipped with DXperience (it can be found at "C:\Users\Public\Documents\DevExpress Demos 13.2\Components\WinForms\CS\GridTutorials\GridRunTimeUsing")
    For more information refer to the following articles:
    Binding to Data
    Binding to Data Specifics
    Views and Levels View Specifics
    Detail Pattern and Clone Views
    Master-Detail: Using Events
    Online video:
    WinForms Grid: Master-Detail Relationships

Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.