Back to Devexpress

TreeMapItemStorage Class

windowsforms-devexpress-dot-xtratreemap-722bbfb6.md

latest5.2 KB
Original Source

TreeMapItemStorage Class

Stores a collection of tree map items and provides them to a tree map control.

Namespace : DevExpress.XtraTreeMap

Assembly : DevExpress.XtraTreeMap.v25.2.dll

NuGet Package : DevExpress.TreeMap

Declaration

csharp
public class TreeMapItemStorage :
    TreeMapDataAdapterBase,
    IXtraSupportDeserializeCollectionItem
vb
Public Class TreeMapItemStorage
    Inherits TreeMapDataAdapterBase
    Implements IXtraSupportDeserializeCollectionItem

Remarks

This class introduces the TreeMapItemStorage.Items property, allowing you to specify the collection of tree map items.

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

Example

To manually provide data for a TreeMap, assign a newly created instance of the TreeMapItemStorage class to the TreeMapControl.DataAdapter property. Then, create several objects of the TreeMapItem class or its descendant class, specify their TreeMapItem.Label and TreeMapItem.Value properties, and add them to the TreeMapItemStorage.Items collection.

Note – to create a group, you will need to add a new TreeMapItem and fill its TreeMapItem.Children collection with tree map items.

csharp
void ConfigureTreeMapDataAdapter() {
    TreeMapItemStorage storage = new TreeMapItemStorage();
    treeMap.DataAdapter = storage;

    TreeMapItem americasGroup = new TreeMapItem { Label = "Americas" };
    americasGroup.Children.Add(new TreeMapItem { Label = "United States", Value = 17.968 });
    americasGroup.Children.Add(new TreeMapItem { Label = "Brazil", Value = 1.8 });
    americasGroup.Children.Add(new TreeMapItem { Label = "Canada", Value = 1.573 });
    storage.Items.Add(americasGroup);

    TreeMapItem europeGroup = new TreeMapItem { Label = "Europe" };
    europeGroup.Children.Add(new TreeMapItem { Label = "Germany", Value = 3.371 });
    europeGroup.Children.Add(new TreeMapItem { Label = "United Kingdom", Value = 2.865 });
    europeGroup.Children.Add(new TreeMapItem { Label = "France", Value = 2.423 });
    europeGroup.Children.Add(new TreeMapItem { Label = "Italy", Value = 1.819 });
    storage.Items.Add(europeGroup);

    TreeMapItem asiaGroup = new TreeMapItem { Label = "Asia" };
    asiaGroup.Children.Add(new TreeMapItem { Label = "China", Value = 11.385 });
    asiaGroup.Children.Add(new TreeMapItem { Label = "Japan", Value = 4.116 });
    asiaGroup.Children.Add(new TreeMapItem { Label = "India", Value = 2.183 });
    storage.Items.Add(asiaGroup);
}
vb
Private Sub ConfigureTreeMapDataAdapter()
    Dim storage As New TreeMapItemStorage()
    treeMap.DataAdapter = storage

    Dim americasGroup As TreeMapItem = New TreeMapItem With {.Label = "Americas"}
    americasGroup.Children.Add(New TreeMapItem With {.Label = "United States", .Value = 17.968})
    americasGroup.Children.Add(New TreeMapItem With {.Label = "Brazil", .Value = 1.8})
    americasGroup.Children.Add(New TreeMapItem With {.Label = "Canada", .Value = 1.573})
    storage.Items.Add(americasGroup)

    Dim europeGroup As TreeMapItem = New TreeMapItem With {.Label = "Europe"}
    europeGroup.Children.Add(New TreeMapItem With {.Label = "Germany", .Value = 3.371})
    europeGroup.Children.Add(New TreeMapItem With {.Label = "United Kingdom", .Value = 2.865})
    europeGroup.Children.Add(New TreeMapItem With {.Label = "France", .Value = 2.423})
    europeGroup.Children.Add(New TreeMapItem With {.Label = "Italy", .Value = 1.819})
    storage.Items.Add(europeGroup)

    Dim asiaGroup As TreeMapItem = New TreeMapItem With {.Label = "Asia"}
    asiaGroup.Children.Add(New TreeMapItem With {.Label = "China", .Value = 11.385})
    asiaGroup.Children.Add(New TreeMapItem With {.Label = "Japan", .Value = 4.116})
    asiaGroup.Children.Add(New TreeMapItem With {.Label = "India", .Value = 2.183})
    storage.Items.Add(asiaGroup)
End Sub

Implements

ITreeMapDataAdapter

Inheritance

Object HierarchicalElement TreeMapElement TreeMapDataAdapterBase TreeMapItemStorage

See Also

TreeMapItemStorage Members

DevExpress.XtraTreeMap Namespace