CustomControl with Height\Width equals 0.01 throws Exception

Posted by: borovyk on 14 September 2017, 7:15 pm EST

    • Post Options:
    • Link

    Posted 14 September 2017, 7:15 pm EST

    [activereports_archive]Hi

    I have a problem with CustomControl in SectionReport. The exception appears on PrintPreview and in Designer, if I set Height\Width from 0.01 to 0 in ActiveReport7 and ActiveReport9. Could you fix this bug?

    Thanks

    Code example:

    [csharp] CustomControl customControl = new CustomControl(typeof(System.Windows.Forms.TextBox));

    customControl.ImageType = ImageTypes.PNG;

    customControl.Width = 10;

    customControl.Height = 0.01f;

    detail.Controls.Add(customControl);[/csharp]

    On PrintPreview an exception appears:

    Parameter is not valid.

    at System.Drawing.Bitmap…ctor(Int32 width, Int32 height, PixelFormat format)

    at System.Drawing.Bitmap…ctor(Int32 width, Int32 height)

    at GrapeCity.ActiveReports.SectionReportModel.CustomControl.#dCn(Object control, Graphics g, ImageTypes imageType, Rectangle drawRect)

    at GrapeCity.ActiveReports.SectionReportModel.CustomControl.#LYA(GraphicsCache cache, Page page, PointF pageOffset, Single startPos, Single endPos)

    at GrapeCity.ActiveReports.SectionReportModel.ARControl.Render(GraphicsCache gRef, Page page, PointF pageOffset, Single startPos, Single endPos)

    at GrapeCity.ActiveReports.SectionReportModel.Section.Render(GraphicsCache cache, Page page, #Ppb drawingLog, PointF pageOffset, Single pageWidth, Single drawStartPos, Single drawEndPos)

    at GrapeCity.ActiveReports.SectionReportModel.Section.Render(GraphicsCache cache, #rqb rData, #Ppb drawingLog)

    at #sxA.#mqb.#LDb()

    at #sxA.#mqb.#SDb(Section section, Int32 insPos)

    at #sxA.#mqb.#SDb(Section section)

    at #sxA.#vqb.#vEb()

    at #sxA.#vqb.#bZA(Page newPage, Single left, Single top, Single right, Single bottom, UInt32 flags, UInt32& status)

    at GrapeCity.ActiveReports.SectionReport.#4yb()

    at GrapeCity.ActiveReports.SectionReport.Run(Boolean syncDocument)

    at GrapeCity.ActiveReports.SectionReport.Run()

    [/activereports_archive]

  • Posted 14 September 2017, 7:15 pm EST

    [activereports_archive]The error most likely occurs because you’re using the System.Windows.Forms.TextBox control. The Height property of the TextBox is of type Int32 which might be causing the error.

    I would suggest you to try using GrapeCity.ActiveReports.SectionReportModel.TextBox instead of the MS TextBox, which does not cause an error.

    [csharp]CustomControl customControl = new CustomControl(typeof(GrapeCity.ActiveReports.SectionReportModel.TextBox));

    customControl.ImageType = ImageTypes.PNG;

    customControl.Width = 10;

    customControl.Height = 0.01f;

    rpt.Sections[“detail”].Controls.Add(customControl);[/csharp]

    If this does not meet your requirement, could you tell the purpose of setting the height to such a small value and the purpose of using the TextBox control.

    Thanks[/activereports_archive]

  • Posted 14 September 2017, 7:15 pm EST

    [activereports_archive]System.Windows.Forms.TextBox is an example and it doesn’t matter.

    Why such a small value? Because the user can input such value in a designer and crashes the application.

    The exception occurs in CustomControl before calling Control.Paint function, so I can’t impact on it. Could you not print CustomControl if size is too small for Bitmap?

    Note. If TextBox has zero Height\Width no exceptions occurs.

    [/activereports_archive]

  • Posted 14 September 2017, 7:15 pm EST

    [activereports_archive]Let me get in touch with the development team on this and get back to you. I would like to inform that if found to be a bug, the fix would be available in the latest version as ActiveReports 7 is no longer in development. Tracking id - 219652[/activereports_archive]

  • Posted 20 December 2017, 3:30 am EST

    The issue you were facing was fixed in AR10 SP2 which can be downloaded from - http://cdn.grapecity.com/ActiveReports/ar10/hotfixes/ActiveReports-v10.2.8627.0.msi

    You could also download the latest version i.e AR12 instead of AR10, which also has the fix -

    https://www.grapecity.com/en/activereports-developer

Need extra support?

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

Learn More

Forum Channels