New to Telerik UI for ASP.NET AJAX? Start a free 30-day trial

A collection of RadTreeNode objects in a RadTreeView control.

The RadTreeNodeCollection class represents a collection of RadTreeNode objects.

  • Use the this[int] to programmatically retrieve a single RadTreeNode from the collection, using array notation.
  • Use the Count property to determine the total number of menu items in the collection.
  • Use the Add(RadTreeNode) method to add nodes in the collection.
  • Use the Remove(RadTreeNode) method to remove nodes from the collection.

Definition

Namespace:Telerik.Web.UI

Assembly:Telerik.Web.UI.dll

Syntax:

C#
public class RadTreeNodeCollection : ControlItemCollection, IList, ICollection, IEnumerable, IStateManager

Inheritance: objectStateManagedCollectionControlItemCollectionRadTreeNodeCollection

Implements: ICollectionIEnumerableIListIStateManager

Inherited Members ControlItemCollection.VisibleChildren<T>()ControlItemCollection.Add(ControlItem)ControlItemCollection.Contains(ControlItem)ControlItemCollection.CopyTo(ControlItem[], int)ControlItemCollection.AddRange(IEnumerable<ControlItem>)ControlItemCollection.IndexOf(ControlItem)ControlItemCollection.Insert(int, ControlItem)ControlItemCollection.Remove(ControlItem)ControlItemCollection.FindChild<TControlItem>(Predicate<TControlItem>)ControlItemCollection.FindChildByText<TControlItem>(string)ControlItemCollection.FindChildByValue<TControlItem>(string)ControlItemCollection.FindChildByAttribute<TControlItem>(string, string)ControlItemCollection.FindChildByValue<TControlItem>(string, bool)ControlItemCollection.FindChildByText<TControlItem>(string, bool)ControlItemCollection.AddItemToParentControls(int, ControlItem)ControlItemCollection.OnInsertComplete(int, object)ControlItemCollection.OnRemoveComplete(int, object)ControlItemCollection.OnClear()ControlItemCollection.SetOwner(ControlItem)ControlItemCollection.SetDirtyObject(object)ControlItemCollection.ParentControlItemCollection.VisibleItemsControlItemCollection.ListStateManagedCollection.Clear()StateManagedCollection.CopyTo(Array, int)StateManagedCollection.CreateKnownType(int)StateManagedCollection.GetEnumerator()StateManagedCollection.GetKnownTypes()StateManagedCollection.OnClearComplete()StateManagedCollection.OnValidate(object)StateManagedCollection.OnInsert(int, object)StateManagedCollection.OnRemove(int, object)StateManagedCollection.SetDirty()StateManagedCollection.Countobject.ToString()object.Equals(object)object.Equals(object, object)object.ReferenceEquals(object, object)object.GetHashCode()object.GetType()object.MemberwiseClone()...

Constructors

Initializes a new instance of the RadTreeNodeCollection class.

C#
public RadTreeNodeCollection(Control parent)
Parameters:parentControl

The owner of the collection.

Properties

Gets the RadTreeNodeobject at the specified index in the current RadTreeNodeCollection.

C#
public RadTreeNode this[int index] { get; set; }
Parameters:indexint

The zero-based index of the RadTreeNode to retrieve.

Property Value:

The RadTreeNode at the specified index in the current RadTreeNodeCollection.

Methods

Appends the specified RadTreeNode object to the end of the current RadTreeNodeCollection.

C#
public void Add(RadTreeNode node)
Parameters:nodeRadTreeNode

The RadTreeNode to append to the end of the current RadTreeNodeCollection.

Example:
cs-api-definition
RadTreeNode newsNode = new RadTreeNode("News");
RadTreeView1.Nodes.Add(newsNode);

Appends the specified array of RadTreeNode objects to the end of the current RadTreeNodeCollection.

C#
public virtual void AddRange(IEnumerable<RadTreeNode> nodes)
Parameters:nodesIEnumerable<RadTreeNode>

The array of RadTreeNode to append to the end of the current RadTreeNodeCollection.

Example:
cs-api-definition
RadTreeNode[] nodes = new RadTreeNode[] { new RadTreeNode("First"), new RadTreeNode("Second"), new RadTreeNode("Third") };
RadTreeView1.Nodes.AddRange(nodes);

Determines whether the specified RadTreeNode object is in the current RadTreeNodeCollection.

C#
public virtual bool Contains(RadTreeNode node)
Parameters:nodeRadTreeNode

The RadTreeNode object to find.

Returns:

bool

true if the current collection contains the specified RadTreeNode object; otherwise, false.

Copies the RadTreeNode instances stored in the current RadTreeNodeCollection object to an System.Array object, beginning at the specified index location in the System.Array.

C#
public virtual void CopyTo(RadTreeNode[] array, int index)
Parameters:arrayRadTreeNode[]

The System.Array to copy the RadTreeNode instances to.

indexint

The zero-based relative index in array where copying begins.

Returns the first RadTreeNode that matches the conditions defined by the specified predicate. The predicate should returns a boolean value.

C#
public RadTreeNode FindNode(Predicate<RadTreeNode> match)
Parameters:matchPredicate<RadTreeNode>

The Predicate <> that defines the conditions of the element to search for.

Returns:

RadTreeNode

Example:
cs-api-definition
void Page_Load(object sender, EventArgs e)
{
RadTreeView1.FindNode(NodeWithEqualsTextAndValue);
}
private static bool NodeWithEqualsTextAndValue(RadTreeNode node)
{
if (node.Text == node.Value)
{
return true;
}
else
{
return false;
}
}

Searches the nodes in the collection for a RadTreeNode which contains the specified attribute and attribute value.

C#
public RadTreeNode FindNodeByAttribute(string attributeName, string attributeValue)
Parameters:attributeNamestring

The name of the target attribute.

attributeValuestring

The value of the target attribute

Returns:

RadTreeNode

The RadTreeNode that matches the specified arguments. Null (Nothing) is returned if no node is found.

This method is not recursive.

Searches all nodes for a RadTreeNode with a Text property equal to the specified text.

C#
public RadTreeNode FindNodeByText(string text, bool ignoreCase)
Parameters:textstring

The text to search for

ignoreCasebool

A Boolean indicating a case-sensitive or insensitive comparison (true indicates a case-insensitive comparison).

Returns:

RadTreeNode

A RadTreeNode whose Text property equals to the specified argument. Null (Nothing) is returned when no matching node is found.

This method is not recursive.

Searches all nodes for a RadTreeNode with a Text property equal to the specified text.

C#
public RadTreeNode FindNodeByText(string text)
Parameters:textstring

The text to search for

Returns:

RadTreeNode

A RadTreeNode whose Text property equals to the specified argument. Null (Nothing) is returned when no matching node is found.

This method is not recursive.

Searches all nodes for a RadTreeNode with a Value property equal to the specified value.

C#
public RadTreeNode FindNodeByValue(string value, bool ignoreCase)
Parameters:valuestring

The value to search for

ignoreCasebool

A Boolean indicating a case-sensitive or insensitive comparison (true indicates a case-insensitive comparison).

Returns:

RadTreeNode

A RadTreeNode whose Value property equals to the specified argument. Null (Nothing) is returned when no matching node is found.

This method is not recursive.

Searches all nodes for a RadTreeNode with a Value property equal to the specified value.

C#
public RadTreeNode FindNodeByValue(string value)
Parameters:valuestring

The value to search for

Returns:

RadTreeNode

A RadTreeNode whose Value property equals to the specified argument. Null (Nothing) is returned when no matching node is found.

This method is not recursive.

Determines the index of the specified RadTreeNode object in the collection.

C#
public virtual int IndexOf(RadTreeNode node)
Parameters:nodeRadTreeNode

The RadTreeNode to locate.

Returns:

int

The zero-based index of tab within the current RadTreeNodeCollection, if found; otherwise, -1.

Inserts the specified RadTreeNode object in the current RadTreeNodeCollection at the specified index location.

C#
public virtual void Insert(int index, RadTreeNode node)
Parameters:indexint

The zero-based index location at which to insert the RadTreeNode.

nodeRadTreeNode

The RadTreeNode to insert.

Removes the specified RadTreeNode object from the current RadTreeNodeCollection.

C#
public void Remove(RadTreeNode node)
Parameters:nodeRadTreeNode

The RadTreeNode object to remove.

Removes the RadTreeNode object at the specified index from the current RadTreeNodeCollection.

C#
public void RemoveAt(int index)
Parameters:indexint

The zero-based index of the node to remove.