I want to load States and Cities (within those states) into a TreeViewAdv control. The results should look like:
The data resides in a SQL Server Table. I can put the dataset into a loop easy enough, but I can't figure out how to tell the treeviewadv to load a state (as a parent node) and a city (as a child node). I know which is which from the data, I just can't see how to programmatically load them into the TreeViewADV. Here is the code I'm running, the results end up recursing over and over again.
Private Sub treeViewAdv2_BeforeExpand(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Tools.TreeNodeAdvBeforeExpandEventArgs) Handles treeViewAdv2.BeforeExpand
If e.Node.ExpandedOnce Then Return
Dim ds As New DataSet
Dim da As SqlDataAdapter
Dim cn As New SqlConnection("server=(local);uid=sa;pwd=;database=Sample")
Dim x As Integer
da = New SqlDataAdapter("select * from StatesCities order by IsCity", cn)
For x = 0 To ds.Tables(0).Rows.Count - 1
Dim StateCityNode As String = RTrim(ds.Tables(0).Rows(x).Item("cStateCityName").ToString())
Dim node As New TreeNodeAdv(StateCityNode)
If you can show me how to do the promoting and demoting of the nodes as they are loaded, I would be most grateful (Please, in VB.NET)
DJDavis Jebaraj Syncfusion Team June 24, 2003 08:19 AM
I have attached a sample that uses a TreeData library that we have developed that shows databinding a TreeViewAdv to a database. The library itself is in c# and the code is included. The sample that uses this library is in VB.NET and you only have to make minor changes in the VB.NET code to make it work with your project.
Please try this and let us know.
ATAdam ThompsonMarch 19, 2018 09:27 PM
I would be interested in seeing the example project as I have a need to databind to a windows forms treeview control.
The link at http://www.syncfusion.com/support/user/uploads/treeadvgridsync.zip is dead.
GSGokul Sainarayanan Syncfusion Team March 20, 2018 12:12 AM
We can load the TreeViewAdv by iterating each element from the DataTable and update the TreeView item. For more information regarding this, please refer the below KB link.