检索列表框中的所有条目for循环代码图表点为C AddY#

检索列表框中的所有条目for循环代码图表点为C AddY#

问题描述:

我想要使用for循环来遍历我的我的listBox1在我的motherForm正确addY值我的listBox1中的所有条目到我的图表第二种形式? listBox1条目是动态的,并且如果添加更多条目,图表应该相应地作出响应。检索列表框中的所有条目for循环代码图表点为C AddY#

图表将正确地生成listBox1中条目数的x轴上的列,但所有列都具有相同的y轴值(仅动态地拉第一个条目而不是每个列)。代码如下所示。

private void Chart_Load(object sender, EventArgs e) 
{    
    for (int i = 1; i <= motherForm.listBox1.Items.Count; i++) 
     this.chart1.Series["Minutes"].Points.AddY(Double.Parse(motherForm.listBox1.Items[0].ToString())); 
} 

你只需要使用i变量的项目。

for (int i = 0; i < motherForm.listBox1.Items.Count; i++) 
    this.chart1.Series["Minutes"].Points.AddY(motherForm.listBox1.Items[i]);