$99 VS $1000+. UI Control for ASP.NET AJAX(contains chart and gridview).
TreeView WinForms Control
Build complex navigation systems and display complex hierarchical structures
Home > WinForms UI Controls > User Manual > Bind TreeView to XML in C#

KetticTreeView Data Binding to XML data

When using the KetticTreeView control, the developers are able to bind this control to XML data source in Windows Forms application. KetticTreeView control for WinForms provides two options available for the interface designers to accomplish the XML data binding. One is to directly load the XML data to the KetticTreeView in Windows Forms, the other is to load the XML data to a DataSet for KetticTreeView data binding.

Load XML for KetticTreeView Data Binding

The following example demonstrates a typical xml data table which contains a Title element, ID, and ParentID. We can directly load the xml data for data binding of KetticTreeView in C# Windows Forms application.

<Toc>
<Node>
<Title>Parent Title</Title>
<id>1</id>
<ParentId></ParentId>
</Node>
<Node>
<Title>Child Title</Title>
<ID>2</ID>
<ParentId>1</ParentId>
</Node>
</Toc>

Load XML to DataSet for KetticTreeView Data Binding

To bind the KetticTreeView to xml via the DataSet, we shall place the above xml file under the KetticTreeView\DataBinding directory, and then run the C# code below from the Load event handler. A DataSet object will be created and the DataSet.ReadXml() method will consumes the data in the xml file.

DataSet tocDataSet = new DataSet("Toc");
tocDataSet.ReadXml("TreeView\\DataBinding\\toc.xml");
this.ketticTreeView1.DataMember = "Node";
this.ketticTreeView1.DisplayMember = "Title";
this.ketticTreeView1.ChildMember = "ID";
this.ketticTreeView1.ParentMember = "ParentId";
this.ketticTreeView1.DataSource = tocDataSet;
UI Controlsfor Windows Forms
.NET WinForms UI Overview.NET WinForms UI Features.NET WinForms UI GuideC# WinForms UI DesignVB.NET WinForms UI Design
WinForms UI Controls