You can do this by handling the graph's KeyDown event, then check the KeyCode property of the KeyEventArgs that's passed to the KeyDown event handler. If it's Keys.Left, call XYCursor.MovePrevious and if it's Keys.Right, call XYCursor.MoveNext. For example, create a new Windows Forms project, add a WaveformGraph to the form, add a cursor to the graph, add an event handler for the graph's KeyDown event, and then use the following code in the event handler:
private void OnGraphKeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Left)
xyCursor1.MovePrevious();
else if (e.KeyCode == Keys.Right)
xyCursor1.MoveNext();
}
Add some code to plot data on the graph, run, and then you can use the left and right arrow keys to
move the cursor left and right through the data.
This solution will only work for one cursor at a time, though. It may be a little trickier in your application since you have two cursors. Did you want this to work for one cursor or both cursors? If both, how do you want to specify which cursor should move when you press the arrow keys?
- Elton