[C#][MSChart] Cursor 없애기
MSChart 확장 라이브러리에 MSChart Extension 이 있다.
이 라이브러리를 사용하면 Zoom과 Pan, Cursor 기능을 쉽게 사용할 수 있다.
GitHub - Code-Artist/MSChartExtension: Windows Forms MSChart Extensions Method
GitHub - Code-Artist/MSChartExtension: Windows Forms MSChart Extensions Method
Windows Forms MSChart Extensions Method. Contribute to Code-Artist/MSChartExtension development by creating an account on GitHub.
github.com
이 라이브러리를 사용중에 Cursor를 프로그램적으로 지우고 싶었는데 아무리 해도 지울 수 있는 방법이 없었다.
라이브러리를 분석해보니까 ClearCursor1() 메소드가 있었다.
그런데 접근한정자가 private인 것이다..
메소드 안을 보니 RemoveAnnotation을 하는 것이다.
그래서 chart의 Annotations 속성을 보니 Count가 4개가 있었다.
{chartAreaName}Cursor_1X
{chartAreaName}Cursor_1Y
{chartAreaName}cursor1_Label_BG
{chartAreaName}cursor1_Label
이 네개의 Annotation을 RemoveAnnotation을 호출하여 제거하도록 하였다.
chartMain.RemoveAnnotation(chartMain.ChartAreas[0].Name + "Cursor_1X");
chartMain.RemoveAnnotation(chartMain.ChartAreas[0].Name + "Cursor_1Y");
chartMain.RemoveAnnotation(chartMain.ChartAreas[0].Name + "cursor1_Label");
chartMain.RemoveAnnotation(chartMain.ChartAreas[0].Name + "cursor1_Label_BG");
그랬더니 잘 지워진다.