Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Collapse]WinForms Controls
  Prerequisites
 [Expand]What's Installed
 [Expand]Build an Application
 [Collapse]Controls and Libraries
  [Expand]Forms and User Controls
  [Expand]Messages, Notifications and Dialogs
  [Expand]Editors and Simple Controls
  [Expand]Ribbon, Bars and Menu
  [Expand]Application UI Manager
  [Expand]Docking Library
  [Collapse]Data Grid
   [Expand]Getting Started
   [Expand]Binding to Data
   [Expand]Grid View
   [Expand]View Technology
   [Expand]Grouping
   [Expand]Sorting
   [Expand]Summaries
   [Expand]Data Editing
   [Expand]Filtering and Locating Rows
   [Expand]Focus and Selection Handling
   [Expand]Processing Rows
   [Expand]Formatting Cell Values
   [Collapse]Master-Detail Relationships
     Master-Detail Overview
    [Collapse]Binding to Data Specifics
      Master-Detail: DataTable Use
      Master-Detail: Using Events
      Master-Detail: Implementing Master-Detail Relationships for Custom Objects
      Implement Master-Detail Relationships for Objects Using the IRelationList Interface
      Implement Master-Detail Relationships for Objects via Collection Properties
    [Expand]View Specifics
    [Expand]Row Specifics
   [Expand]Asynchronous Image Load
   [Expand]Export and Printing
   [Expand]Appearance and Conditional Formatting
   [Expand]Batch Modifications
   [Expand]Hit Information
   [Expand]Hints
   [Expand]Popup Menus
   [Expand]Saving and Restoring Layouts
   [Expand]Visual Elements
   [Expand]Design-Time Features
   [Expand]Examples
   [Expand]End-User Capabilities
    Included Components
  [Expand]Vertical Grid
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Chart Control
  [Expand]Diagrams
  [Expand]Gauges
  [Expand]Map Control
  [Expand]Scheduler
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Expand]Printing-Exporting
  [Expand]PDF Viewer
   Reporting
  [Expand]Snap
  [Expand]TreeMap Control
 [Expand]Common Features
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Document Server
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Implement Master-Detail Relationships for Objects Using the IRelationList Interface

You can provide master-detail relationships on the data source level, by implementing specific methods for your object that provide data for the grid control. In this instance, the grid will display the detail data you'll supply in detail Views. This topic shows how to implement master-detail relationships by implementing the IRelationList interface for your data source object. The interface's methods allow you to dynamically load the detail data.

To implement master-detail relationships for your data source object, you can also implement the IRelationListEx interface instead. This is the extended version of the IRelationList interface. See below to learn more.

The IRelationList and IRelationListEx interfaces can be implemented for both runtime created data and for .NET data structures (for instance, System.Data.DataView objects).

Expanded IRelationList and IRelationListEx Interfaces

Either the IRelationList or IRelationListEx interface must be implemented for a master data source. Their methods should provide information about the relationships, and supply the detail data. The IRelationList interface's members are listed below:

The IRelationListEx interface extends the IRelationList interface. When using the IRelationListEx interface, you can provide a different number of master-detail relationships for different master rows and customize the display captions of the relationships. The two additional methods of this interface are:

Note that the grid's master-detail specific events can be used in combination with the methods mentioned above when implementing a master-detail mode. These events occur after the corresponding methods are called. For instance, the GridView.MasterRowGetChildList event allows you to override the result of the IRelationList.GetDetailList method.

Expanded Implementing the IRelationList Interface

Let us consider a simple example of implementing the IRelationList interface for a custom Records class from the GridUnboundMasterView tutorial.

The Records class represents an array of Record objects, and serves as a data source for a grid control. It contains three items (Customers, Products and Shippers), each of which is associated with corresponding detail data.

Detail data is provided via the IRelationList methods.
Detail data for the Customers, Products and Shippers items is represented by custom classes - ChildRecordsCustomers, ChildRecordsProducts and ChildRecordsShippers. The implementation of these classes is quite simple and is omitted here for brevity.

Expanded See Also

How would you rate this topic?​​​​​​​