For-Each-Loop over all TextObjects in the report ?

Hello,


I am loading a FASTREPORT report in a VB.Net (or C#) program (desktop program, WinForms).

How can I use FOR-EACH in the VB.Net program to run through all "TextObject" objects of the report.

The Report.AllObjects.InnerList is unfortunately "locked".

The aim is to find all "TextObject" objects and evaluate the respective TAG-Property.

Thank you very much

Frank

Comments

  • I'll answer myself again face-smile

    The solution is:

    Dim _obj As ObjectCollection = _Report.ForEachAllConvectedObjects(_Report)


    For Each _item As Object In _obj  

      If _item.ClassName = "TextObject" Then  

        Dim _LangId As Int16 = 0

        If Not String.IsNullOrEmpty(AsendiaFrameWork.NZ(_item.Tag, "")) Then  

          If Int16.TryParse(_item.Tag, _LangId) Then 

            _item.Text = appLanguage.GetLanguageOnlyText(_LangId)

          End If

        End If

      End If

    Next

    I didn't have ForEachAllConvectedObjects on the screen face-sad

    Sometimes you see the forest..... and so....

    Frank

  • Hello!

    To iterate through all TextObjects in the report, there is no need to access the private AllObjects.InnerList. Alongside the ForEachAllConvectedObjects(_Report) method you found, the report.AllObjects collection supports the standard For Each loop directly.

    In VB.NET:

    For Each item As Base In report.AllObjects
    Dim txt = TryCast(item, TextObject)
    If txt IsNot Nothing AndAlso Not String.IsNullOrEmpty(Convert.ToString(txt.Tag)) Then
    txt.Text = Translate(txt.Tag.ToString())
    End If
    Next
    


    And in C#:

    foreach (TextObject txt in report.AllObjects.OfType<TextObject>())
    {
    // process txt.Tag / txt.Text
    }
    
This discussion has been closed.