How to retrieve the selected range in the .Net WinForms Chart Control?
OK, well, I figured it out. Here's the scoop:
There's a SelectionRangeChang*ing* event, and when that one runs the ChartArea.CursorX.SelectionStart
and ChartArea.CursorX.SelectionEnd
fields have correct values in them. But the user hasn't released the mouse button yet, so you should just store them.
When the user releases the mouse button, the SelectionRangeChang*ed* event fires. Somehow it's designed in such a way that SelectionStart and SelectionEnd are reset to NaN (just like the NewSelectionStart
and NewSelectionEnd
fields in the event parameters). What you have to do is to use the values that you squirreled away from the other event handler now that you know the time is right to use them.
So there you have it! Hopefully this answer will save someone else from wasting time.