System.Web.UI.WebControls Namespace TreeNode Class
.NET Framework version 2.0
Returns the level at which a TreeNode object is displayed.
Script |
[ Integer variable = ] TreeNode.Depth |
This property can only be used programmatically; it cannot be set when declaring the control.
variable |
The level at which a node is displayed. |
The property is read only with no default value.
Use the Depth property to determine the level at which a TreeNode is displayed in a TreeView control.
The depth represents the number of hierarchy levels between the current node and the root node. For example, a root node has a depth of 0. A subnode of a root node has a depth of 1, and so on.
The following example demonstrates how to use the Depth property to determine the level at which a TreeNode is displayed in a TreeView, and take appropriate action based on the depth.
void PopulateNode ( Object source, TreeNodeEventArgs e ) {
switch ( e.Node.Depth ) {
case 0 :
getCategories ( e.Node );
break;
case 1 :
getSubCategories ( e.Node );
break;
}
}
Sub PopulateNode ( source As Object, e As TreeNodeEventArgs )
Select Case e.Node.Depth
Case 0
getCategories(e.Node)
Case 1
getSubCategories(e.Node)
End Select
End Sub |
|
C# |
VB |
Show me
TreeNode Members