asp.net.ph

TreeNode.Parent Property

System.Web.UI.WebControls Namespace   TreeNode Class


.NET Framework version 2.0

Returns the parent TreeNode of the current node.

Syntax


Script [ TreeNode node = ] TreeNode.Parent

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

Property Value


node A TreeNode object that represents the parent of the current node.

The property is read only with no default value.

Remarks

Use the Parent property to determine the parent of the current node or to access the parent node's properties.

NOTE: A root node does not have a parent node.

To access the subnodes of the current node, use the ChildNodes property.

Example

The following example demonstrates how to use the Parent property to access the properties of the current node's parent node.

void getSelectedValues ( Object source, EventArgs e ) {
   TreeNode selectedNode = myTreeView.SelectedNode;
   message.Text = "Selected TreeNode Text: <b>" + selectedNode.Text + "</b><br>" +
      "Selected TreeNode Value: <b>" + myTreeView.SelectedValue + "</b>";
   if ( selectedNode.Parent != null )
      message.Text += "<p>Selected TreeNode's Parent Text: <b>" + selectedNode.Parent.Text + "</b><br>" +
         "Selected TreeNode's Parent Value: <b>" + selectedNode.Parent.Value + "</b>";
   else
      message.Text += "<p>The selected item is a root menu item that does not have a parent.";

}
  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