I'm new to learning winforms and i'm stuck on the following problem and I do not think what I have done is the correct way, so any help would be appreciated.
I have 4 textboxes such as the following
private void txtBxPlayer1Bid_TextChanged(object sender, EventArgs e)
{
txtBxFundsAvialable.Text = (Convert.ToInt32(txtBxFundsAvialable.Text) - Convert.ToInt32(txtBxPlayer1Bid.Text)).ToString();
}
The 5th textbox txtBxFundsAvialable simple subtract the value of txtBxPlayer1Bid from txtBxFundsAvialable.
In designer.cs I have
this.txtBxPlayer1Bid.Leave += new System.EventHandler(this.txtBxPlayer1Bid_TextChanged);
The problem I have is, if I have 100 in txtBxFundsAvialable and enter 10 in txtBxPlayer1Bid the value in txtBxFundsAvialable should be 90, but txtBxPlayer1Bid etc seem to go into a loop and the value in txtBxFundsAvialable becomes 60. 4 textboxes X 10.
This happens for any of the 4 textboxes
The only way I can solve the problem is to set the values of the 4 textboxes to 0 in the txtBxFundsAvialable_TextChanged as shown below.
private void txtBxFundsAvialable_TextChanged(object sender, EventArgs e)
{
if (Convert.ToInt32(txtBxPlayer1Bid.Text) > 4 || (Convert.ToInt32(txtBxPlayer2Bid.Text)> 4 || (Convert.ToInt32(txtBxPlayer3Bid.Text)> 4) || (Convert.ToInt32(txtBxPlayer2Bid.Text)> 4)))
{
txtBxPlayer1Bid.Text = "0";
txtBxPlayer2Bid.Text = "0";
txtBxPlayer3Bid.Text = "0";
txtBxPlayer4Bid.Text = "0";
}
}
Is what I'm doing the correct way, as stated at the beginning, I'm new to winforms and it a canny leanning curve