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

Looping through controls

1 Answer 230 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 19 Aug 2019, 10:15 AM

The below code works in a Tererik report

                    Me.txt001.Value = drw("int001")
                    Me.txt002.Value = drw("int002")
                    Me.txt003.Value = drw("int003")

where drw is a DataRow

I have around 600 controls on a report and need to be able to loop through the various textboxes.

The following works in a Visual Studio Form but not in a Telerik report

                    For intCounter As Integer = 1 To 3
                        Me.Controls("txt00" & CStr(intCounter)).Text = drw("int00" & CStr(intCounter)).ToString
                    Next

It does not like Me.Controls("txt00" & CStr(intCounter)).Text

Any ideas, otherwise I would have to painstakingly refer to all controls by name.

Thanks.

 

 

 

 

 

1 Answer, 1 is accepted

Sort by
0
Eric R | Senior Technical Support Engineer
Telerik team
answered on 21 Aug 2019, 03:14 PM
Hi John,

The Telerik.Reporting.Report namespace contains a collection of read-only Items that can be looped through. See the Access Items for Calling Application documentation for more details. For example, one way to output the name of each item would be as follows.

Dim instanceReportSource As Telerik.Reporting.InstanceReportSource = DirectCast(Me.ReportViewer1.ReportSource, Telerik.Reporting.InstanceReportSource)
Dim report As Telerik.Reporting.Report = DirectCast(instanceReportSource.ReportDocument, Telerik.Reporting.Report)
For Each item In report.Items
    Debug.WriteLine(item.Name)
Next

Please let me know if you need any additional information. Thank you for using the Reporting Forums.

Regards,

Eric R | Technical Support Engineer
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
John
Top achievements
Rank 1
Answers by
Eric R | Senior Technical Support Engineer
Telerik team
Share this question
or