Back to Devexpress

Lesson 1 - Create a Simple Unbound TreeMap

windowsforms-115719-controls-and-libraries-treemap-getting-started-lesson-1-create-a-simple-unbound-treemap.md

latest5.3 KB
Original Source

Lesson 1 - Create a Simple Unbound TreeMap

  • Oct 23, 2024
  • 3 minutes to read

This lesson details the steps required to build a simple unbound TreeMap diagram.

To create a simple unbound chart, do the following.

Step 1. Create a New Project

In this step, a new WinForms application will be created and a TreeMap Control will be added to the application’s Form.

  • Run MS Visual Studio.

  • Create a new Windows Forms Application project.

  • Add the TreeMapControl to the application’s Form.

  • Dock the TreeMap in the form.

All the preparatory work is complete. In the next step, the TreeMap will be populated with data.

Step 2. Populate a TreeMap with Data

In this step, the following data table will be visualized using the TreeMap Control.

RegionCountryGDP (million of USD)
AmericasUnited States17.418
AmericasBrazil2.353
AsiaChina10.380
AsiaJapan4.616
AsiaIndia2.049
EuropeGermany3.859
EuropeUnited Kingdom2.945
EuropeFrance2.846
EuropeItaly2.147
EuropeRussia1.857

To do this, follow the steps below.

  • Assign the TreeMapItemStorage object to the TreeMapControl.DataAdapter property.

  • Then, expand the adapter’s properties and click the ellipsis button opposite the TreeMapItemStorage.Items property. In the invoked TreeMapItem Collection Editor , expand the list of available items clicking the Expand button. After that, select TreeMapItem to add the first group item.

  • For the newly created item, set the TreeMapItem.Label to Americas. This value will be used as the group label.

  • Add children elements. To do this, click the ellipsis button opposite the TreeMapItem.Children property. In the invoked TreeMapItem Collection Editor dialog, click Add to add a leaf item.

  • For the added leaf item, set the TreeMapItem.Label to United States and the TreeMapItem.Value to 17.418.

  • Repeat previous steps to add table rows to the TreeMap.

The image below represents the launched application with a TreeMap control populated with data.

Proceed to the next step to learn how to customize the appearance of the TreeMap control.

Step 3. Customize the Appearance of the TreeMap

In this step, the style of the group header, text patterns of group headers and leafs will be configured. Also, the colorizer that provides colors to tree map items will be customized.

Now, the application is finished.

Result

Run the application. The following image represents the launched application.

See Also

Lesson 2 - Create a TreeMap Bound to Flat Data