Category / Section
How to add custom controls in WinForms TreeViewAdv?
1 min read
Custom controls
In TreeviewAdv, you can add custom controls to its TreeNodeAdv by using TreeNodePrimitive class and CustomControl property. The following code example demonstrates the same.
C#
Syncfusion.Windows.Forms.Tools.TreeNodePrimitive TreeNodePrimitive1 = new Syncfusion.Windows.Forms.Tools.TreeNodePrimitive(); TreeNodePrimitive1.Index = 0; //To set the custom control as PrimitiveType TreeNodePrimitive1.PrimitiveType = Syncfusion.Windows.Forms.Tools.PredefinedPrimitiveTypes.CustomControl; //Add nodes primitives collection TreeNodeAdv4.Primitives.AddRange(new Syncfusion.Windows.Forms.Tools.TreeNodePrimitive[] {TreeNodePrimitive1}); TreeNodeAdv4.ShowLine = true; //To add custom control to child node this.treeViewAdv1.Nodes[2].Nodes[0].CustomControl = this.comboBoxAdv2;
VB
Dim TreeNodePrimitive1 As Syncfusion.Windows.Forms.Tools.TreeNodePrimitive = New Syncfusion.Windows.Forms.Tools.TreeNodePrimitive() TreeNodePrimitive1.Index = 0 'To set the custom control as PrimitiveType TreeNodePrimitive1.PrimitiveType = Syncfusion.Windows.Forms.Tools.PredefinedPrimitiveTypes.CustomControl 'Add nodes primitives collection TreeNodeAdv4.Primitives.AddRange(New Syncfusion.Windows.Forms.Tools.TreeNodePrimitive() {TreeNodePrimitive1}) TreeNodeAdv4.ShowLine = True TreeNodeAdv4.Text = ""TreeNodeAdv3.Nodes.AddRange(New Syncfusion.Windows.Forms.Tools.TreeNodeAdv() {TreeNodeAdv4}) 'To add custom control to child nodeMe.treeViewAdv1.Nodes(2).Nodes(0).CustomControl = Me.comboBoxAdv2
Reference link: https://help.syncfusion.com/windowsforms/treeview/treenodeadvcustomization#custom-controls