This is a migrated thread and some comments may be shown as answers.

loop through all controls

2 Answers 510 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Jonam
Top achievements
Rank 1
Jonam asked on 26 Jan 2011, 10:47 AM
Hello,

when i'm in a asp.net website i can loop through all the controls with

(foreach Control c in this.Controls)

Is this is also possible in telerik report to loop through all the controls?

kind regards,

Jonam

2 Answers, 1 is accepted

Sort by
0
Tony
Top achievements
Rank 1
answered on 10 Nov 2011, 10:15 PM
I'd like to be able to do the same thing. I have a user defined function that I'm successfully using to pull client specific themes. I want to iterate through the controls and set the styles. I can't do it in the designer, because I don't have the themes until AFTER I've bound to my data.

0
Steve
Telerik team
answered on 11 Nov 2011, 09:15 AM
Hi guys,

You can use the ReportItemBase[] ItemCollection.Find(Type type, bool recursive) overload of the Find method of the Items property. For example:

ReportItemBase[] allTextBoxes = report.Items.Find(typeof(Telerik.Reporting.TextBox), true);
int i  = 0;
foreach (Telerik.Reporting.TextBox textBox in allTextBoxes)
{
   textBox.Value = (i++).ToString();
}

This code will gather recursively all the TextBox report items in a report and will set a sequential number for their Value property.

Hope this helps.

Best wishes,
Steve
the Telerik team

Q2’11 SP1 of Telerik Reporting is available for download (see what's new). Get it today.

Tags
General Discussions
Asked by
Jonam
Top achievements
Rank 1
Answers by
Tony
Top achievements
Rank 1
Steve
Telerik team
Share this question
or