05-03-2012 11:26 PM
I have two cursors in one scatterGraph. The operation mode of the first cursor is dragXY. I do not want the user to be able to drag the second cursor. is there a way to have the second cursor respond to "mouse click" while the second cursor can be dragged?
Thanks,
yajai
05-04-2012 11:46 AM
Hi there,
I quickly tested moving the second cursor depending on if you move the first one. Its quiet easy if you hook on to the XYCursor.AfterMove event.
Here is the code snippet!
public partial class Form1 : Form
{
// offset the values as you like.
private double xOffset = 2;
private double yOffset = 2;
public Form1()
{
InitializeComponent();
// use either ToPlot or Floating for the 1st cursor
xyCursor1.SnapMode = NationalInstruments.UI.CursorSnapMode.ToPlot;
xyCursor2.SnapMode = NationalInstruments.UI.CursorSnapMode.Fixed;
SetCursorPosition2();
// some data on the graph
scatterGraph1.PlotXY(new double[] { 1, 2, 3, 5, 6, 8, 4, 2 }, new double[] { 1, 2, 3, 5, 6, 8, 4, 2 });
}
private void SetCursorPosition2()
{
xyCursor2.XPosition = xyCursor1.XPosition + xOffset;
xyCursor2.YPosition = xyCursor1.YPosition + yOffset;
}
private void xyCursor1_AfterMove(object sender, NationalInstruments.UI.AfterMoveXYCursorEventArgs e)
{
SetCursorPosition2();
}
}
Cheers!!
Vijet Patankar
National Instruments
05-04-2012 02:26 PM
Thank you! It works very well.