asp.net.ph

TreeNode.Depth Property

System.Web.UI.WebControls Namespace   TreeNode Class


.NET Framework version 2.0

Returns the level at which a TreeNode object is displayed.

Syntax


Script [ Integer variable = ] TreeNode.Depth

This property can only be used programmatically; it cannot be set when declaring the control.

Property Value


variable The level at which a node is displayed.

The property is read only with no default value.

Remarks

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.

Example

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;
   }
}
  C# VB

 Show me 

See Also

TreeNode Members Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph