How to show or hide cursor on WinForms MS chart, C#

868 views Asked by At

I have to use System.Windows.Forms.DataVisualization.Charting.Chart in my project

I created hair cross pair of System.Windows.Forms.DataVisualization.Charting.Cursor() on a chart; I would like to show or hide these CursorX, CursorY on chart if needed. The idea is to toggle cursor on chart by DoubleClick event. I cannot find any property (i.e. CursorX.Visible) or method (i.e. CursorX.hide()) to do it.

To hide, I tried to copy cursor object to global private cursor object and dispose cursor object from chart.ChartArea; to show - [re]create cursor object again from global object. But it caused more troubles because now I need to check everywhere if cursor object exists

Anybody knows a better way of hiding cursor?

P.S. I also used before National Instruments Measurements Studio chart - that is designed mach better, everything is thought out and much easier...

1

There are 1 answers

1
Igor K On

I found a way: To make cursor "disappear", set ChartArea[0].CursorX.LineDashStyle to "NotSet"

To [re]appear, set this property to anything else from the choices: "Solid, Dot, Dash, etc."

Example: chartArea2.CursorX.LineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.Solid;