1

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...

Igor K
  • 31
  • 2
  • Why cant you Cursor.hide() on mousehover? The idea is you want the cursor gone when it goes over your chart? – aaarianme Mar 17 '21 at 21:27
  • Unfortunately there is no Chart.ChartAreas[0].Cursor; only Chart.ChartAreas[0].CursorX and Chart.ChartAreas[0].CursorY. Both do not have method Hide(). Why to hide - in one situation I want to have only vert cursor line so when I drag it somewhere on a form I would show Y values from multiple traces (Series) at this X, in another situation show only horizontal line which sticks to max or min of trace. Or it can be too crowded so I want to hide cursor to de-clatter a bit. – Igor K Mar 19 '21 at 00:15

1 Answers1

1

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;

Igor K
  • 31
  • 2