Live Chat Icon For mobile
Live Chat Icon

How can I determine the node level of a node in my treeview

Platform: WinForms| Category: TreeView

Here is a code snippet suggested by Mattias Sjögren on the microsoft.public.dotnet.languages.csharp newsgroup.

	public int NodeLevel(TreeNode node)
		int level = 0;
		while ((node = node.Parent) != null) level++;
		return level;
	Public Sub NodateLevel(ByVal node as TreeNode) As Integer
		Dim level as Integer = 0
		While Not node Is Nothing
			node = node.Parent
			level = level + 1
		End While
	End Sub

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.