We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

adding columns programmatically treeview

Thread ID:





90528 Oct 6,2009 05:14 PM UTC Oct 8,2009 11:43 AM UTC WPF 1
Tags: Tools
Rafael Huapaya
Asked On October 6, 2009 05:14 PM UTC

how can I fill a treeview programmatically adding columns manually, i have this code.

For i As Integer = 0 To _Categorias.Count - 1
Dim newItem As TreeViewItemAdv = New TreeViewItemAdv
newItem.Header = _Categorias(i).Cai_nombre_completo
newItem.IsEditable = False

For j As Integer = 0 To _Activos.Count - 1
If _Categorias(i).Cai_codigo = _Activos(j).cai_codigo Then
Dim newSubItem As TreeViewItemAdv = New TreeViewItemAdv
newSubItem.Header = _Activos(j).act_nombre_largo
newSubItem.IsEditable = False
End If

but, i want more columns.

Thanks. :)

C. Sudha [Syncfusion]
Replied On October 8, 2009 11:43 AM UTC

Hi Rafael,

Thanks for choosing Syncfusion products.

By setting MultiColumnEnable property to true, you can add the column to the treeview. The below code snippet will help you to add the header to the column:


Dim TreeViewAdv1 As New TreeViewAdv()
TreeViewAdv1.MultiColumnEnable = True
TreeViewAdv1.ShowRootLines = True
TreeViewAdv1.ItemsSource = StudentInfo.CreateStudentList()
TreeViewAdv1.ItemTemplate = TryCast(Me.Resources("dataTemplate2"), HierarchicalDataTemplate)
TreeViewAdv1.ItemContainerStyle = TryCast(Me.Resources("TreeViewItemStyle2"), Style)

Dim c1 As New TreeViewColumn()
c1.DisplayMemberBinding = New Binding("RollNumber")
c1.Header = "Roll No."
c1.Width = 100
Dim c2 As New TreeViewColumn()
c2.DisplayMemberBinding = New Binding("FirstName")
c2.Header = "First Name"
c2.Width = 150
Dim c3 As New TreeViewColumn()
c3.DisplayMemberBinding = New Binding("LastName")
c3.Header = "Last Name"
c3.Width = 150

TreeViewAdv1.Columns = New TreeViewColumnCollection()

treeborder.Child = TreeViewAdv1

For more information, Please download the attached sample.

Please let me know if you have any questions.




This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon