Dynamically draw a line in sub report

Posted by: swapnil.kumbhar on 1 September 2019, 4:24 pm EST

    • Post Options:
    • Link

    Posted 1 September 2019, 4:24 pm EST - Updated 30 September 2022, 5:35 pm EST

    I am trying to create a drawing in a sub report, for that I need to draw lines dynamically while generating the report, I am trying to use Line control for that But I am not able to view the line in the report., Below is the code snippet I am using

    private void DiagramSectionReport_ReportStart(object sender, EventArgs e)
            {
                var line = new Line
                {
                    
                    X1 = 10,
                    Y1 = 100,
                    X2 = 200,
                    Y2 = 100,
                    LineColor = Color.Red,
                    LineWeight = 3
                };
                this.Sections[1].Controls.Add(line);
                this.detail.Controls.Add(line);
    
    
    
                GrapeCity.ActiveReports.SectionReportModel.Label lblCategoryID = new GrapeCity.ActiveReports.SectionReportModel.Label();
                lblCategoryID.Location = new PointF(0, 0.05F);
                lblCategoryID.Text = "Category ID";
                lblCategoryID.Alignment = TextAlignment.Center;
                lblCategoryID.Font = new System.Drawing.Font("Arial", 10, FontStyle.Bold);
                this.Sections[0].Controls.Add(lblCategoryID);
                this.Sections[1].Controls.Add(lblCategoryID);
            }
    

    I am able to view the Label but not able to view the line, Am I doing something wrong here?

    I have attached 2 images below to

    1 . Design of sub reports showing 3 sections

    2. My reports(pdf’s) section showing the output of my sub report.

  • Posted 2 September 2019, 7:42 am EST

    Hello,

    The line might be rendered in your report, but to view it in your section, you may want to decrease the coordinate values and use certain other properties as follows:

    var line = new Line
               {
                   Name="line1",
                   X1 = 3.34,
                   Y1 = 0.062,
                   X2 = 4.34,
                   Y2 = 0.062,
       	Height=0,
       	Top=0.104,
       	Left=3.968,
                   LineColor = Color.Red,
                   LineWeight = 3,
       	LineStyle=LineStyle.Solid
               };
               this.Sections[1].Controls.Add(line);
               this.detail.Controls.Add(line);
    

    Regards,

    Esha

  • Posted 2 September 2019, 9:38 am EST

    Thank you very much Esha, If you can can provide a link to the documentation of Line that will be a great help

  • Posted 2 September 2019, 10:09 am EST

    Hello,

    Please refer to the following documentation link of Line control:

    https://help.grapecity.com/activereports/webhelp/AR13/webframe.html#LineSectionReport.html

    Thanks,

    Mohit

Need extra support?

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

Learn More

Forum Channels