从图中删除网格线

时间:2013-04-22 09:31:34

标签: c# graph

我在页面上打印图表。我可以绘制和修改图形,但它有一些不能更改或删除的网格线。这是代码和屏幕截图:

        Chart chart2 = new Chart();
        ChartArea area2 = new ChartArea();

        chart2.ChartAreas.Add(area2);
        Series s2 = new Series();
        s2.Name = "S2";
        s2.ChartType = SeriesChartType.Line;
        s2.XValueType = ChartValueType.Double;
        s2.YValueType = ChartValueType.Double;
        chart2.Series.Add(s2);
        chart2.Series["S2"].Points.DataBindXY(x2, y2);


        Rectangle myRec1 = new System.Drawing.Rectangle(30,25,100,100);
        // draw!
        chart2.Printing.PrintPaint(e.Graphics, myRec1);

图片:Screen shot

我尝试了系列的几乎所有属性和SO,但我认为这不是原因。

1 个答案:

答案 0 :(得分:1)

将以下适当的语句添加到您的代码中;

area2.AxisX.MajorGrid.Enabled  = False
area2.AxisX2.MajorGrid.Enabled = False
area2.AxisY.MajorGrid.Enabled  = False
area2.AxisY2.MajorGrid.Enabled = False
area2.AxisX.MinorGrid.Enabled  = False
area2.AxisX2.MinorGrid.Enabled = False
area2.AxisY.MinorGrid.Enabled  = False
area2.AxisY2.MinorGrid.Enabled = False