How to delete grid lines from Chart in WindowsForm?

后端 未结 3 1707
猫巷女王i
猫巷女王i 2020-12-09 16:02

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

Thanks!

相关标签:
3条回答
  • 2020-12-09 16:26

    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"

    0 讨论(0)
  • 2020-12-09 16:38

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

    0 讨论(0)
  • 2020-12-09 16:47

    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

    0 讨论(0)
提交回复
热议问题