The Syncfusion native Blazor components library offers 70+ UI and Data Viz web controls that are responsive and lightweight for building modern web apps.
.NET PDF framework is a high-performance and comprehensive library used to create, read, merge, split, secure, edit, view, and review PDF files in C#/VB.NET.
I want to load States and Cities (within those states) into a TreeViewAdv control. The results should look like:
- Texas
Abilene
Houston
San Antonio
- Connecticut
New Haven
Hartford
etc.
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)
da.Fill(ds, "StatesCities")
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)
e.Node.Nodes.Add(node)
Next
End Sub
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 01:19 PM UTC
Hi Bob,
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.
http://www.syncfusion.com/support/user/uploads/treeadvgridsync.zip
Please try this and let us know.
Regards,
Davis
ATAdam ThompsonMarch 20, 2018 02:27 AM UTC
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 05:12 AM UTC
Hi Adam,
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.