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. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to create NodeID property for the TreeNodeAdv in WinForms TreeViewAdv?

Platform: WinForms |
Control: TreeViewAdv

Create custom property

In the TreeNodeAdv, you can add custom properties by creating custom TreeNodeAdv class that is inherited from the TreeNodAdv. The following code example demonstrates the same.


//Creates custom TreeNode class.
public class CustomTreeNodeAdv : TreeNodeAdv
    public CustomTreeNodeAdv()
        // Initializes according to the need.
    private int m_NodeId;
    /// <summary>
    /// Gets/Sets the ID in the TreeNodeAdv.
    /// </summary>
    public int ID
        get { return m_NodeId; }
        set { m_NodeId = value; }
for (int i = 0; i < 100; i++)
    CustomTreeNodeAdv node = new CustomTreeNodeAdv();
    node.ID = i;
    node.Text = "Node" + i.ToString();
//Displays the Node ID.
MessageBox.Show("ID: " + (this.treeViewAdv1.SelectedNode as CustomTreeNodeAdv).ID.ToString());



'Creates custom TreeNode class.
Public Class CustomTreeNodeAdv
    Inherits TreeNodeAdv
    Public Sub New()
        'Initializes according to the need.
    End Sub
    Private m_NodeId As Integer
    ''' <summary>
    ''' Gets/Sets the ID in the TreeNodeAdv.
    ''' </summary>
    Public Property ID() As Integer
  Return m_NodeId
        End Get
        Set(ByVal value As Integer)
  m_NodeId = value
        End Set
    End Property
End Class
For i As Integer = 0 To 99
    Dim node As New CustomTreeNodeAdv()
    node.ID = i
    node.Text = "Node" & i.ToString()
Next i
' Displays the Node ID.
MessageBox.Show("ID: " & (TryCast(Me.treeViewAdv1.SelectedNode, CustomTreeNodeAdv)).ID.ToString())


C#: http://www.syncfusion.com/downloads/support/directtrac/136015/TreeViewAdvNodeId-690740322.zip

VB: http://www.syncfusion.com/downloads/support/directtrac/138428/TreeViewAdvNodeId_VB251737780.zip

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
You must log in to leave a comment

Please sign in to access our KB

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

Up arrow icon

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

Live Chat Icon For mobile