SgDotNet
Singapore Professional .NET User Group -For Cool Developers

Use Of TreeView Control

rated by 0 users
This post has 1 Reply | 1 Follower

Top 150 Contributor
Posts 12
kokchern Posted: 11-14-2006 5:36 PM

How to use the treeview  which get its data from MS Access to form the tree.

Thanks. 

Top 25 Contributor
Posts 157

Think there a few ways to go about doing it, but I do not have the luxury of time to provide the actual coding. Nevertheless, here is what you can do.

Databinding Method
Using OleDB, create a dataset from the Access mdb file via the use of a OleDbDataAdapter. Next is to add a DataRelation to the DataSet to create a hierarchy, and set Nested to True.
Next step is to create a XmlDatasource (since TreeView only accepts SiteMap and XmlDataSource) and set Data to the DataSet.GetXml. Optional is to add a Xml StyleSheet via TransformFile.
Finally is to set XmlDataSource as the DataSource of TreeView.
Note: I was not able to really get this to work (display) the way I wanted, even after using the Xml StyleSheet, for I am still not really familiar with the TreeView control and the Xml StyleSheet.

Nodes Adding
The best bet is to use the created DataSet and using For.. Next loop to add the TreeNodes to the TreeView yourself.

While you can also use the new AccessDataSource data control to create the DataSet, you would need a DataView (or DataReader) to act as the middle-man. The reason being AccessDataSource.Select(DataSourceSelectArguments) returns a DataView (or DataReader, depending on the DataSourceMode you set).

Page 1 of 1 (2 items) | RSS
Copyright SgDotNet 2004-2008
Powered by Community Server (Commercial Edition), by Telligent Systems