FieldCollection add method depricated

Posted by: mtwede on 16 November 2018, 6:36 am EST

    • Post Options:
    • Link

    Posted 16 November 2018, 6:36 am EST

    so we are creating flexreports dynamically in code and when I compile I get a compiler warning that :

    Warning 1 ‘Public Function Add(name As String, text As String, rc As C1.Win.Interop.Rect) As C1.Win.FlexReport.Field’ is obsolete. C:\Users\mtwede\Documents\Visual Studio 2013\Projects\4_5\KnowledgeBase\NWAKbReport\Forms\Printing\frmACCAPrintReport.vb 333 17 NWAKbReport

    I have searched this site as well as the internet and can’t seem to find the new method/replacement.

    Am concerned about doing an upgrade to the tools until i can get this resolved.

    Thanks in advance for any help you can provide.

    Regards,

    Mike

  • Posted 16 November 2018, 6:41 am EST

    p.s. we are trying to add a header(report title) to one of our reports.

        'Report Header section (Title)
        With C1FlexReport1.Sections(SectionTypeEnum.Header)
            .Height = HeaderSizeHeight
            .Visible = True
            .BackColor = Color.AliceBlue
            f = .Fields.Add("ACCAHeader1", mReportTitle, New Rectangle(CInt(HeaderSizeLeft), CInt(HeaderSizeTop), CInt(ReportSizeWidth), CInt(HeaderSizeHeight)))
            f.Font.Size = 12
            f.Font.Bold = True
            f.ForeColor = Color.Black
        End With
    
  • Posted 18 November 2018, 5:15 pm EST

    Hello Mike,

    Only the particular overload of Add method is deprecated as it adds legacy field to the report. You can use the other overload Add(FieldBase) instead.

    http://help.grapecity.com/componentone/NetHelp/FlexReport/webframe.html#C1.Win.FlexReport.4~C1.Win.FlexReport.FieldCollection~Add(FieldBase).html

    The related parameters from the deprecated overload can be set in the code using the TextField’s Left, Top, Width and Height properties, as follows:

         Dim f As New TextField
            'Report Header section (Title)
            With C1FlexReport1.Sections(SectionTypeEnum.Header)
                .Height = 1440 * 3
                .Visible = True
                .BackColor = Color.AliceBlue
                f.Font.Size = 12
                f.Font.Bold = True
                f.ForeColor = Color.Black
                f.Left = 0
                f.Top = 0
                f.Width = 1440 * 2
                f.Height = 1440
                f.Text = "Product Details"
                .Fields.Add(f)
            End With
    

    Best Regards,

    Esha

  • Posted 19 November 2018, 4:01 am EST

    Works like a charm.

    I had seen the other add overloads, but was not sure how to specify/define the ‘fieldbase’ parameter. Was trying to create an instantiation of a fieldbase object somehow.

    However, I still have one more question. In your example you create a textfield but in the link they specify a field. Both work, but is one preferred over the other? which should i use?

    Mike

  • Posted 19 November 2018, 3:18 pm EST

    Hello,

    FieldBase is an abstract base class for all C1FlexReport field types. Thus, it refers to fields added to the report itself, just as stated in the description.

    The class “Field” is used generally in reports converted from C1Report to C1FlexReport. After the conversion, all the fields belong to Field class in C1FlexReport.

    By default, FlexReport adds fields of FieldBase type and hence, the same is suggested for use.

    Best Regards,

    Esha

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels