TreeNode Level

If you spend any time working with Treeviews, I can't imagine not needing this or having to invent it yourself:

Windows Forms FAQ - Windows Forms TreeView

[VB.NET]

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

I edited into this:


Private Function NodeLevel(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 Function

About this Entry

This page contains a single entry by tmichael published on June 22, 2003 4:55 PM.

Hide Datagrid Expanders was the previous entry in this blog.

Very Useful Moveable Type Plug-in is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.