Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
850
How can I add a target Line to my ultrachart?
posted

Hello everyone

Why do I get this exception in my program at the moment
when I try to add a target line in my ultrachart?

The exception says something like this:
Error creating form. See Exception.InnerException for more details.
Error: Object reference not set to an instance of an object.


I'm using this code to add my target line

            Dim target As Double = 1.25
            Dim axisY As IAdvanceAxis = TryCast(e.Grid("Y"), IAdvanceAxis)
            Dim axisX As IAdvanceAxis = TryCast(e.Grid("X"), IAdvanceAxis)
            Dim targetYCoord As Integer = CInt(axisY.Map(target))
            Dim xStart As Integer = CInt(axisX.MapMinimum)
            Dim xEnd As Integer = CInt(axisX.MapMaximum)
            Dim targetLine As New Line(New Point(xStart, targetYCoord), New Point(xEnd, targetYCoord))

            targetLine.PE.Stroke = Color.Red
            targetLine.PE.StrokeWidth = 3

            e.SceneGraph.Add(targetLine)

I got that exception in this part
Dim targetYCoord As Integer = CInt(axisY.Map(target))
But I don't know why.

Any response or suggestion, I will be very grateful.
I want my ultrachart have a similar appearance to the image of the LineGraph.rar file
that I'm attaching. I only have to add the target line ... Please help me.
By the way, my code is in the LineGraph.rar too

LineGraph.rar