How to delete grid lines from Chart in WindowsForm?

廉价感情. 提交于 2019-12-29 05:03:28

问题


How can I remove grid lines from chart? I use standard Chart library.

Thanks!


回答1:


Assuming a single ChartArea, you can try these settings:

chart1.ChartAreas[0].AxisX.MajorGrid.LineWidth = 0;
chart1.ChartAreas[0].AxisY.MajorGrid.LineWidth = 0;

Otherwise you may want to use:

chart1.ChartAreas["ChartArea1"].AxisX.MajorGrid.LineWidth = 0;
chart1.ChartAreas["ChartArea1"].AxisY.MajorGrid.LineWidth = 0;

where, "ChartArea1" is the Series Property-->Chart-->Chart Area "ChartArea1"




回答2:


You can disable MajorGrid or MinorGrid of each of the axis of the desired chart-area:

mainChart.ChartAreas[0].AxisX.MajorGrid.Enabled = false;
mainChart.ChartAreas[0].AxisX.MinorGrid.Enabled = false;
mainChart.ChartAreas[0].AxisY.MajorGrid.Enabled = false;
mainChart.ChartAreas[0].AxisY.MinorGrid.Enabled = false;

as seen below: https://github.com/sinairv/MSChartWrapper/blob/master/MSChartWrapper/ChartWrapper.cs#L58-L61




回答3:


If you're just using the designer, you can navigate your way to the MajorGrid property like this...



来源:https://stackoverflow.com/questions/8871287/how-to-delete-grid-lines-from-chart-in-windowsform

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!