You misunderstand the meaning of the AddXY
method.
It doesn't change the y- or any values.
AddXY
means that a new DataPoint
is added to the Points
collection.
In your code each will have an x-value of 1
and the y-values of the two points are 2
and 4
. To do so you would write, maybe:
barChart.Series[0].Points[0].YValues[0] += D;
If your numbers are decimals you will need to cast to double, which is the base number type for all Chart values:
barChart.Series[0].Points[0].YValues[0] += (double)D;
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…