I'm trying to display a total in a text box however the variable the text box outputs will only update if the value assigned to it is greater than the last value instead of adding to the last value.
private void PictureBoxWindFarmMouseClick(object sender, MouseEventArgs e)
{
decimal captot = 0;
// Read mouse-click position
int x = e.X;
int y = e.Y;
//collects varibles from the form
int hei = _heightTrackBar.Value;
float rad = (_radiusTrackBar.Value)*0.01f ;
int bla = Convert.ToInt32(_numberOfBladesUpDown.Value);
Color pol = colorDialog1.Color;
Color rot = colorDialog2.Color;
bool clo = _clockwiseCheckBox.Checked;
decimal cap = _capacityUpDown.Value;
captot += cap;
// Create wind turbine at this position, uses collected varibles
WindTurbine turbine = new WindTurbine( hei, rad, bla, clo, pol, rot, cap, x, y);
// Add wind turbine to farm list
_turbines.Add(turbine);
// Force redraw of the picture box to show changes
_pictureBoxWindFarm.Refresh();
_statusLabel.ResetText();
_statusLabel.Text = ("these"+ _turbines.Count + "wind turbines can generate a total of" + captot + "MW of power.");
}
textbox at lower left
textbox not adding
updates if value is greater
question from:
https://stackoverflow.com/questions/65648758/textbox-wont-update-total 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…