C#WindowForm中给chart控件添加参考线的用法 ,用的是 StripLine集合的方式。
private void button2_Click(object sender, EventArgs e)
{
upperLimit = double.Parse(tB1.Text.Trim());
lowerLimit = double.Parse(tB2.Text.Trim());
//定义图表区域
this.chart1.ChartAreas.Clear();
ChartArea chartArea1 = new ChartArea("C1");
this.chart1.ChartAreas.Add(chartArea1);
//设置图表显示样式
this.chart1.ChartAreas[0].AxisY.Maximum = upperLimit+3;
this.chart1.ChartAreas[0].AxisY.Minimum = lowerLimit-3;
this.chart1.ChartAreas[0].AxisX.Interval = 5;
this.chart1.ChartAreas[0].AxisX.MajorGrid.LineColor = System.Drawing.Color.Silver;
this.chart1.ChartAreas[0].AxisY.MajorGrid.LineColor = System.Drawing.Color.Silver;