Back to Devexpress

TreeMapHierarchicalDataAdapter Class

windowsforms-devexpress-dot-xtratreemap-446d22f7.md

latest4.7 KB
Original Source

TreeMapHierarchicalDataAdapter Class

A data adapter that allows you to provide hierarchical data to the Tree Map.

Namespace : DevExpress.XtraTreeMap

Assembly : DevExpress.XtraTreeMap.v25.2.dll

NuGet Package : DevExpress.TreeMap

Declaration

csharp
public class TreeMapHierarchicalDataAdapter :
    TreeMapDataAdapterBase,
    IGroupIndexProvider
vb
Public Class TreeMapHierarchicalDataAdapter
    Inherits TreeMapDataAdapterBase
    Implements IGroupIndexProvider

Remarks

This class introduces the TreeMapHierarchicalDataAdapter.DataSource property allowing you to specify the data source provided to the Tree Map and the TreeMapHierarchicalDataAdapter.Mappings collection that allows you to specify data object mappings to tree map items.

For more information about Data Adapters, refer to the Providing Data topic.

Example

To provide hierarchical data to a TreeMap, create a TreeMapHierarchicalDataAdapter object and assign it to the TreeMapControl.DataAdapter property. Then, specify the adapter’s data source object using the TreeMapHierarchicalDataAdapter.DataSource property. To configure how hierarchical data should be converted to tree map items, use HierarchicalDataMapping objects. The HierarchicalDataMapping.LabelDataMember property allows you to specify a label data member, the HierarchicalDataMapping.ValueDataMember property - a value data member, the HierarchicalDataMapping.ChildrenDataMember property - a data member containing children items, and the HierarchicalDataMapping.Type property - the type of items on the current nesting level.

csharp
void CreateTreeMapDataAdapter() {
    TreeMapHierarchicalDataAdapter dataAdapter = new TreeMapHierarchicalDataAdapter();
    dataAdapter.DataSource = CreateStatistics();

    // Fill the Mappings collection using mappings specifying 
    // how to convert data objects to tree map items.
    dataAdapter.Mappings.Add(new TreeMapHierarchicalDataMapping {
        Type = typeof(CountryStatistics),
        LabelDataMember = "Name",
        ChildrenDataMember = "EnergyStatistics"
    });
    dataAdapter.Mappings.Add(new TreeMapHierarchicalDataMapping {
        Type = typeof(EnergyInfo),
        LabelDataMember = "Type",
        ValueDataMember = "Value"
    });

    treeMap.DataAdapter = dataAdapter;
}
vb
Private Sub CreateTreeMapDataAdapter()
    Dim dataAdapter As New TreeMapHierarchicalDataAdapter()
    dataAdapter.DataSource = CreateStatistics()

    ' Fill the Mappings collection using mappings specifying 
    ' how to convert data objects to tree map items.
    dataAdapter.Mappings.Add(New TreeMapHierarchicalDataMapping With {.Type = GetType(CountryStatistics), .LabelDataMember = "Name", .ChildrenDataMember = "EnergyStatistics"})
    dataAdapter.Mappings.Add(New TreeMapHierarchicalDataMapping With {.Type = GetType(EnergyInfo), .LabelDataMember = "Type", .ValueDataMember = "Value"})

    treeMap.DataAdapter = dataAdapter
End Sub

Implements

ITreeMapDataAdapter

Inheritance

Object HierarchicalElement TreeMapElement TreeMapDataAdapterBase TreeMapHierarchicalDataAdapter

See Also

TreeMapHierarchicalDataAdapter Members

DevExpress.XtraTreeMap Namespace