Is there any way to draw with code?
Is there any way to draw with code?
I've been trying to draw a line without using shapes, because I need to draw the line with given angle. I've tried to write:
private void SetLineOnPage(StiReport report) {
StiPage page1= (StiPage) report.GetComponentByName("Page1");
StiVerticalLinePrimitive lineVertikal;
lineVertikal = new Stimulsoft.Report.Components.StiVerticalLinePrimitive();
lineVertikal.ClientRectangle = new Stimulsoft.Base.Drawing.RectangleD(24, 1, 0.0254, 16);
lineVertikal.Color = System.Drawing.Color.Black;
Guid guid = Guid.NewGuid();
lineVertikal.Guid = guid.ToString();
lineVertikal.Name = "LineVertikalDick";
lineVertikal.Size = 3F;
lineVertikal.EndCap = new StiCap(10, Stimulsoft.Base.Drawing.StiCapStyle.None, 10, true, System.Drawing.Color.Black);
lineVertikal.Interaction = null;
lineVertikal.StartCap = new StiCap(10, Stimulsoft.Base.Drawing.StiCapStyle.None, 10, true, System.Drawing.Color.Black);
lineVertikal.Page = page1;
lineVertikal.Parent = page1;
page1.Components.AddRange(new Stimulsoft.Report.Components.StiComponent[] {
lineVertikal});
}
}
to beforeprint event but it does not work.
private void SetLineOnPage(StiReport report) {
StiPage page1= (StiPage) report.GetComponentByName("Page1");
StiVerticalLinePrimitive lineVertikal;
lineVertikal = new Stimulsoft.Report.Components.StiVerticalLinePrimitive();
lineVertikal.ClientRectangle = new Stimulsoft.Base.Drawing.RectangleD(24, 1, 0.0254, 16);
lineVertikal.Color = System.Drawing.Color.Black;
Guid guid = Guid.NewGuid();
lineVertikal.Guid = guid.ToString();
lineVertikal.Name = "LineVertikalDick";
lineVertikal.Size = 3F;
lineVertikal.EndCap = new StiCap(10, Stimulsoft.Base.Drawing.StiCapStyle.None, 10, true, System.Drawing.Color.Black);
lineVertikal.Interaction = null;
lineVertikal.StartCap = new StiCap(10, Stimulsoft.Base.Drawing.StiCapStyle.None, 10, true, System.Drawing.Color.Black);
lineVertikal.Page = page1;
lineVertikal.Parent = page1;
page1.Components.AddRange(new Stimulsoft.Report.Components.StiComponent[] {
lineVertikal});
}
}
to beforeprint event but it does not work.
-
- Posts: 6245
- Joined: Tue Mar 20, 2018 5:34 am
Re: Is there any way to draw with code?
Hello,
You should add also start and end points.
The simple way - it is to add the necessary component in the designer, then open the Code Tab and use the same code.
Thank you.
You should add also start and end points.
The simple way - it is to add the necessary component in the designer, then open the Code Tab and use the same code.
Thank you.
- Attachments
-
- Screenshot 2022-06-21 103932.png (203.3 KiB) Viewed 644 times
Re: Is there any way to draw with code?
Thanks for answering. Where is that code part I really cannot find BTW the version is 2.1
- Attachments
-
- 111.png (19.97 KiB) Viewed 641 times
-
- Posts: 6245
- Joined: Tue Mar 20, 2018 5:34 am
Re: Is there any way to draw with code?
Hello,
In the JS designer, the Code tab is not available.
Thank you.
In the JS designer, the Code tab is not available.
Thank you.
Re: Is there any way to draw with code?
So thats the point... How can I write code to the report for create line with given angle?
Is it possible to solve that problem with writing expressions on beforeprint or somewhere else?
I just need to create a polygon with given angles...
Is it possible to solve that problem with writing expressions on beforeprint or somewhere else?
I just need to create a polygon with given angles...
-
- Posts: 6245
- Joined: Tue Mar 20, 2018 5:34 am
Re: Is there any way to draw with code?
Hello,
You should use the Shape component for that task.
Thank you.
You should use the Shape component for that task.
Thank you.
Re: Is there any way to draw with code?
I tried to use shapes, but there is not any angle property to write expression sir. That situation is so broken. I think there is no way
Re: Is there any way to draw with code?
You can use Shape of type 'Diagonal Up' or 'Down' and set width and height suitable to your angle (simple mathematics).
Re: Is there any way to draw with code?
Alright thats right. I can really set the angle with width and height properties, but I could not change the width and height property of that line dynamically,
An example, I have some data like rightAngle and leftAngle like 45-45,
lets say if leftAngle = 45 then myShape.Width = 10 and myShape.Height = 10
the main problem is that, how can I say that in report
I've tried some expressions on beforeprint event but its not working.
An error occurs and it says "The script in the 'BeforePrintEvent' event in the 'Shape3' component doesn't work in the interpretation mode."
An example, I have some data like rightAngle and leftAngle like 45-45,
lets say if leftAngle = 45 then myShape.Width = 10 and myShape.Height = 10
the main problem is that, how can I say that in report
I've tried some expressions on beforeprint event but its not working.
An error occurs and it says "The script in the 'BeforePrintEvent' event in the 'Shape3' component doesn't work in the interpretation mode."
- Attachments
-
- 2.png (30.21 KiB) Viewed 609 times
-
- 1.png (139.38 KiB) Viewed 609 times
Re: Is there any way to draw with code?
Hi,
please take a look in the manuals to learn about how to use events.
All events has the object to change as parameter (name: sender, type: object). You have to parse this 'sender' to your component type and set your properties on this object.
please take a look in the manuals to learn about how to use events.
All events has the object to change as parameter (name: sender, type: object). You have to parse this 'sender' to your component type and set your properties on this object.