Version

Binding WinTree to a Hierarchical Data Source

Before You Begin

The WinTree™control can be used to represent hierarchical data in a tree like structure. In addition to the column support, it has the ability to bind to a data source. When bound to a data source, UltraTreeColumnSet and UltraTreeNodeColumn objects are automatically generated since the AutoGenerateColumnSets property is set to true by default.

What you will Accomplish

You will learn how to bind WinTree to the Customers and Orders table of the Northwind database.

Follow these Steps

  1. From the Microsoft® Visual Studio® Toolbox, drag and drop an UltraTree onto your form.

  2. In the WinTree control’s Properties window, select the DataSource property to display the drop-down list. In the drop-down list, click the “Add Project Data Source…” link.

WinTree Binding WInTree to a Hierarchical Data Source 01.png
  1. The Data Source Configuration Wizard will appear. Select Database and click Next.

  2. Click New Connection to configure the connection string. The Add Connection dialog appears.

  3. Make sure you have Microsoft SQL Server (Sql Client) under Data Source. Set the server name to the server you are using, .\SQLEXPRESS in this case. Set the database to Northwind.

WinTree Binding WInTree to a Hierarchical Data Source 02.png
  1. Click OK. You are returned to the Choose your Data Connection screen.

  2. Click Next.

  3. Expand the Tables node and select the checkboxes next to Customers and Orders Table. Click Finish.

WinTree Binding WInTree to a Hierarchical Data Source 03.png
  1. In the WinTree control’s DataSource property window, drop-down the dialog, and expand the Other Data Sources section. A Northwind dataset will be listed with the Customers and Orders table. Select the Orders table associated with the dataset first, as this will represent the child table. Then select the Customers table which will represent the parent table. A dataset, BindingSource, and TableAdapter will be generated and added as components to your form.

  2. Now the WinTree will display the columns that will be shown when it is rendered.

WinTree Binding WInTree to a Hierarchical Data Source 04.png
  1. Save and run the application. You will see the WinTree control filled with data from the Customers table, and if you expand a node, the associating Orders table will be visible.

WinTree Binding WInTree to a Hierarchical Data Source 05.png