2017-11-04 83 views
0

我想要使用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())); 
} 

回答

-1

你只需要使用i變量的項目。

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