Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

how do you add cursors dynamically?

Hi -

I'm trying to add a cursor and plot for each series I'm given. Below is the code that adds the plot and the cursor; this code is only called if the request is not a postback. I can come to the page initially, but any sort of postback results in an error: XYCursor.Plot and XYCursor do not belong to the same graph. Is there something else I need to do to avoid that error?

Thanks!
Terry

    Private Function AddPlot(ByVal s As Series, ByVal plotNumber As Integer) As NationalInstruments.UI.ScatterPlot
        If s.YAxisIndex > 0 And Not m_secondAxisEnabled Then
            AddSecondAxis()
        End If
        Dim p As New NationalInstruments.UI.ScatterPlot(Graph.XAxes(0), Graph.YAxes(s.YAxisIndex))
        p.LineWidth = 2
        p.PlotXY(m_presenter.GetXValues(), m_presenter.GetSeriesDataPoints(s))
        p.LineColor = GetColor(plotNumber)
        Graph.Plots.Add(p)

        Dim c As New XYCursor(p)
        c.VerticalCrosshairMode = CursorCrosshairMode.FullLength
        c.HorizontalCrosshairMode = CursorCrosshairMode.FullLength
        c.SnapMode = CursorSnapMode.NearestPoint
        Graph.Cursors.Add(c)

        Return p
    End Function
0 Kudos
Message 1 of 2
(2,926 Views)
Hey Terry,

Unfortunately, it looks like you have found a bug in Measurement Studio.  I was able to replicate the behavior, and I have passed on this information to R&D.  It should be fixed in the next version of Measurement Studio.  In the mean time, a possible workaround would be to create the cursors at design time and just make them initially invisible.  Then you could make them visible as you needed the cursors.  I know this is not the best solution, but this is the only available work around at this time. 

Thanks,
Pat P.
Software Engineer
National Instruments
0 Kudos
Message 2 of 2
(2,899 Views)