2013-06-21 96 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