Looping through controls

2 posts, 0 answers
  1. John
    John avatar
    1 posts
    Member since:
    Sep 2014

    Posted 19 Aug 2019 Link to this post

    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

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

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







  2. Eric R | Senior Technical Support Engineer
    Eric R | Senior Technical Support Engineer avatar
    463 posts

    Posted 21 Aug 2019 Link to this post

    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

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


    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
Back to Top