New to Telerik Reporting? Start a free 30-day trial

Provides utility methods that perform common tasks involving nodes in a LayoutElement tree.

Definition

Namespace:Telerik.Reporting.Processing

Assembly:Telerik.Reporting.dll

Syntax:

C#
public static class ElementTreeHelper

Inheritance: objectElementTreeHelper

Methods

Determines whether a parent layout element contains immediate child having a specified name.

C#
public static bool ContainsChildWithName(LayoutElement parent, string name)
Parameters:parentLayoutElement

The parent element to search within.

namestring

The name to search for.

Returns:

bool

true if an layout element having the specified parent and name is found; Otherwise, false.

Example:
cs-api-definition
void DetailSection_ItemDataBinding_Using_ContainsChildWithName(object sender, EventArgs e)
{
Processing.DetailSection processingInstance = (Processing.DetailSection)sender;
if (Processing.ElementTreeHelper.ContainsChildWithName(processingInstance, "textBox1"))
{
processingInstance.Style.BackgroundColor = System.Drawing.Color.Blue;
}
}

Searches for all layout elements with a specified name within a specified parent.

C#
public static LayoutElement[] FindChildByName(LayoutElement parent, string name, bool searchAllChildren)
Parameters:parentLayoutElement

The parent element to search within.

namestring

The name to search for.

searchAllChildrenbool

If true, all descendants within the specified parent are matched (deep search). Otherwise, only immediate children are matched.

Returns:

LayoutElement[]

Array containing all matching by name children / descendants. If no elements are found an empty array is returned

Example:
cs-api-definition
void DetailSection_ItemDataBinding_Using_FindChildByName(object sender, EventArgs e)
{
Processing.DetailSection processingInstance = (Processing.DetailSection)sender;
Processing.LayoutElement[] elements = Processing.ElementTreeHelper.FindChildByName(processingInstance, "textBox1", true);
foreach (Processing.LayoutElement child in elements)
{
Processing.VisualElement visualChild = child as Processing.VisualElement;
if (null != visualChild)
{
visualChild.Style.BackgroundColor = System.Drawing.Color.Blue;
}
}
}

Returns the immediate child layout element within a specified parent at specified index.

C#
public static LayoutElement GetChildByIndex(LayoutElement parent, int index)
Parameters:parentLayoutElement

The parent element to search within.

indexint

The zero-based index of the child to get.

Returns:

LayoutElement

Layout element having the specified parent at the specified index.

Example:
cs-api-definition
void DetailSection_ItemDataBinding_Using_GetChildByIndex(object sender, EventArgs e)
{
Processing.DetailSection processingInstance = (Processing.DetailSection)sender;
Processing.LayoutElement child = Processing.ElementTreeHelper.GetChildByIndex(processingInstance, 0);
Processing.VisualElement visualChild = child as Processing.VisualElement;
if (null != visualChild)
{
visualChild.Style.BackgroundColor = System.Drawing.Color.Blue;
}
}

Returns the first immediate child layout element within a specified parent having a specified name.

C#
public static LayoutElement GetChildByName(LayoutElement parent, string name)
Parameters:parentLayoutElement

The parent element to search within.

namestring

The name to search for.

Returns:

LayoutElement

Layout element having the specified name and parent.

Example:
cs-api-definition
void DetailSection_ItemDataBinding_Using_GetChildByName(object sender, EventArgs e)
{
Processing.DetailSection processingInstance = (Processing.DetailSection)sender;
Processing.LayoutElement child = Processing.ElementTreeHelper.GetChildByName(processingInstance, "textBox1");
Processing.VisualElement visualChild = child as Processing.VisualElement;
if (null != visualChild)
{
visualChild.Style.BackgroundColor = System.Drawing.Color.Blue;
}
}

Returns all immediate child layout elements within a specified parent.

C#
public static IEnumerable<LayoutElement> GetChildElements(LayoutElement parent)
Parameters:parentLayoutElement

The parent element.

Returns:

IEnumerable<LayoutElement>

Enumerable of all layout elements having the specified parent. If the parent does not have children, an empty enumeration is returned.

Example:
cs-api-definition
void DetailSection_ItemDataBinding_Using_GetChildElements(object sender, EventArgs e)
{
Processing.DetailSection processingInstance = (Processing.DetailSection)sender;
IEnumerable&lt;Processing.LayoutElement&gt; elements = Processing.ElementTreeHelper.GetChildElements(processingInstance);
foreach (Processing.LayoutElement child in elements)
{
Processing.VisualElement visualChild = child as Processing.VisualElement;
if (null != visualChild)
{
visualChild.Style.BackgroundColor = System.Drawing.Color.Blue;
}
}
}

Returns the zero-based index of the first occurrence of a layout element with a specified name within a parent.

C#
public static int IndexOfChildWithName(LayoutElement parent, string name)
Parameters:parentLayoutElement

The parent element to search within.

namestring

The name to search for.

Returns:

int

The zero-based index of the first occurrence of a layout element having the specified name within the specified parent.

Example:
cs-api-definition
void DetailSection_ItemDataBinding_Using_IndexOfChildWithName(object sender, EventArgs e)
{
Processing.DetailSection processingInstance = (Processing.DetailSection)sender;
int index = Processing.ElementTreeHelper.IndexOfChildWithName(processingInstance, "textBox1");
if (index &gt;= 0)
{
Processing.LayoutElement child = Processing.ElementTreeHelper.GetChildByIndex(processingInstance, index);
Processing.VisualElement visualChild = child as Processing.VisualElement;
if (null != visualChild)
{
visualChild.Style.BackgroundColor = System.Drawing.Color.Blue;
}
}
}