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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

adding columns programmatically treeview

Thread ID:

Created:

Updated:

Platform:

Replies:

90528 Oct 6,2009 01:14 PM Oct 8,2009 07:43 AM WPF 1
loading
Tags: Tools
Rafael Huapaya
Asked On October 6, 2009 01:14 PM

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
TreeViewAdv1.Items.Add(newItem)

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
newItem.Items.Add(newSubItem)
End If
Next
Next

but, i want more columns.

Thanks. :)

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

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:

[VB]

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()
TreeViewAdv1.Columns.Add(c1)
TreeViewAdv1.Columns.Add(c2)
TreeViewAdv1.Columns.Add(c3)

treeborder.Child = TreeViewAdv1

For more information, Please download the attached sample.

Please let me know if you have any questions.

Regards,
SudhaC.



MultiColumnTreeView_17f7cf4f.zip

CONFIRMATION

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.

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

;