2013-06-21 94 views
3

我正在使用Visual Studio 2010中的标准图表库。 图表工作正常,但我无法更改轴网格线样式。 这些性质已在Form1.Designers.cs图表网格线样式

chartArea3.Name = "ChartArea1"; 
     this.chart1.ChartAreas.Add(chartArea3); 
     legend3.Name = "Legend1"; 
     this.chart1.Legends.Add(legend3); 
     this.chart1.Location = new System.Drawing.Point(12, 68); 
     this.chart1.Name = "chart1"; 
     series5.ChartArea = "ChartArea1"; 
     series5.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; 
     series5.Color = System.Drawing.Color.Red; 
     series5.Legend = "Legend1"; 
     series5.Name = "Temp"; 
     series6.ChartArea = "ChartArea1"; 
     series6.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; 
     series6.Color = System.Drawing.Color.Blue; 
     series6.Legend = "Legend1"; 
     series6.Name = "Umid"; 
     this.chart1.Series.Add(series5); 
     this.chart1.Series.Add(series6); 
     this.chart1.Size = new System.Drawing.Size(647, 182); 
     this.chart1.TabIndex = 8; 
     this.chart1.Text = "chart1"; 
     this.chart1.ChartAreas[0].AxisY.Interval=5; 

设定我想有轴网格型点或dashdots。我曾尝试用:

this.chart1.ChartAreas[0].AxisX.LineDashStyle.?????? 

但我不知道如何将财产和/或如果上面的代码部分行是正确的分配。

回答

6

最后,我猜中了:

this.chart1.ChartAreas[0].AxisX.MajorGrid.LineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.DashDotDot; 
     this.chart1.ChartAreas[0].AxisY.MajorGrid.LineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.DashDotDot; 

这是工作的,允许访问的栅格轴的线条样式。

this.chart1.ChartAreas[0].AxisX.MajorGrid.LineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.availableStileSelectionHere; 
1

你会想看看ChartDashStyle枚举。您的选择应该是DashDashDot,DashDotDot,Dot,SolidNotSet

AxisX属于Charting.Axis类型,因此这是表示行类型信息的地方。

所以尝试:

this.chart1.ChartAreas[0].AxisX.LineDashStyle.Dot 

this.chart1.ChartAreas[0].AxisX.LineDashStyle.DashDot 
+0

谢谢约翰,但我在我的代码中尝试过bot行,并且不起作用。我修改了我的帖子中的代码,显示了我从默认设置中添加的所有属性集。 – FeliceM

+0

您是否使无效/刷新图表?您是否能够看到图表中的其他更改,与您尝试更改轴类型的方式相同(如同代码中的相同位置)? – John

+0

上述代码中设置interval = 5的最后一行工作正常。所有其他行默认已经存在。 – FeliceM