Skip to main content

TreeMapHierarchicalDataAdapter.DataSource Property

Gets or sets the object that is the data source of the data adapter.

Namespace: DevExpress.XtraTreeMap

Assembly: DevExpress.XtraTreeMap.v24.1.dll

NuGet Package: DevExpress.TreeMap

Declaration

[DefaultValue(null)]
[XtraSerializableProperty(XtraSerializationVisibility.Hidden)]
public object DataSource { get; set; }

Property Value

Type Default Description
Object null

A Object that is the data source.

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.

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;
}
See Also