Skip to Content
author's profile photo Former Member
Former Member

Add LineObject - Erro as Section not found?

Hi to all,

I'm using Asp.net 2.0-C# and Crystal Report 11 R2.

I want to add a Line dynamically (ie. programatically) this is my code

public void Method1()

{

AddLine(30,40,20,50,1,"Left");

}

public void AddLine(int leftPoint, int topPoint, int rightPoint, int bottomPoint, int lineThickness, string Position)

{

try

{

CrystalDecisions.ReportAppServer.ReportDefModel.Section boSection= boReportClientDocument.ReportDefController.ReportDefinition.DetailArea.Sections[0];

CrystalDecisions.ReportAppServer.ReportDefModel.LineObject Line = new CrystalDecisions.ReportAppServer.ReportDefModel.LineObject();

Line.Left = 1;

Line.Top = 50;

Line.Right = 100;

Line.Bottom = 50;

Line.LineThickness = 2;

Line.LineStyle = CrystalDecisions.ReportAppServer.ReportDefModel.CrLineStyleEnum.crLineStyleSingle;

boReportClientDocument.ReportDefController.ReportObjectController.Add(Line,boSection,-1);

}

catch(Exception ex)

{

throw ex;

}

}

but it raise an error as

Section is not found.

Experts please tell me how to solve this problem?

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Dec 18, 2008 at 06:55 AM

    Hi to all,

    i changed my code like this

    public void AddLine(int leftPoint, int topPoint, int rightPoint, int bottomPoint, int lineThickness, string Position)

    {

    CrystalDecisions.ReportAppServer.ReportDefModel.LineObject Line = new CrystalDecisions.ReportAppServer.ReportDefModel.LineObject();

    Line.Left = leftPoint;

    Line.Top = topPoint;

    Line.Right = rightPoint;

    Line.Bottom = bottomPoint;

    Line.LineThickness = lineThickness;

    Line.LineStyle = CrystalDecisions.ReportAppServer.ReportDefModel.CrLineStyleEnum.crLineStyleSingle ;

    Line.EnableExtendToBottomOfSection = true;

    if (Position.ToUpper() == "HEAD")

    {

    Line.SectionName = boSection.Name;

    Line.EndSectionName = boSection.Name;

    boReportClientDocument.ReportDefController.ReportObjectController.Add(Line, boSection, -1);

    }

    if (Position.ToUpper() == "DETAIL")

    {

    Line.SectionName = boSection.Name;

    Line.EndSectionName = boSection.Name;

    boReportClientDocument.ReportDefController.ReportObjectController.Add(Line, boSection, 1);

    }

    }

    its drawing line but when i export into excel file then the line object is not rendered in the excel file, could any body tell me why its happen?

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.