Quit Button Click Event.
`void buttn2_Click(object sender, EventArgs e) //QUIT BUTTON CLICK EVENT.
{
if (MessageBox.Show("LEAVE CURRENT GAME?", "QUIT CONFIRMATION", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
this.Controls.Remove(buttn); .. PLAY AGAIN BUTTON.
this.Controls.Remove(buttn2);
for (int i = 0; i <= gencount; i++)
{
this.Controls.Remove(panel[i]);
this.Controls.Remove(label200[i]);
this.Controls.Remove(label100[i]);
this.Controls.Remove(Tbox[i]);
}
this.Controls.Remove(AttemptsRem);
this.Controls.Remove(AttemptNum);
this.Controls.Remove(TimeRem);
this.Controls.Remove(Min);
this.Controls.Remove(Sec);
this.Controls.Remove(misc);
this.ReftoForm2.Show(); To go back to the starting form
}
else
buttn.Focus();
}
Form1 activate Event.
private void Form1_Activated(object sender, EventArgs e)
{
if (ui_formCowsAndBulls.rdbSinglePlayer.Checked == true)//Static variable
{
//GetAllTheWords(); .. Am still working on getting a the 4 letter words
//GetDistinctElements(); .. randomly out of a list.
textBox1.PasswordChar = '*';
textBox1.Focus();
foreach (string val in distinctWords)
{
if (val == "ABLE") .. For single player,the guess word is ABLE.
textBox1.Text = val;
}
}
else
{
textBox1.Text = string.Empty;
textBox1.Enabled = true;
textBox1.Focus();
}
//textBox1.Focus();
}
PLAY AGAIN CLICK EVENT
private void buttn_Click(object sender, EventArgs e) //PLAY AGAIN CLICK EVENT.
{
for (int i = 0; i <= gencount; i++)
{
this.Controls.Remove(panel[i]);
this.Controls.Remove(label200[i]);
this.Controls.Remove(label100[i]);
this.Controls.Remove(Tbox[i]);
}
this.Controls.Remove(AttemptsRem);
this.Controls.Remove(AttemptNum);
textBox1.Text = string.Empty;
textBox1.Enabled = true;
textBox1.Focus();
incrpanel = 0; gencount = 0; count = 10;
this.Controls.Remove(TimeRem);
this.Controls.Remove(Min);
this.Controls.Remove(Sec);
this.Controls.Remove(misc);
this.textBox1.PasswordChar = '*';
this.Controls.Remove(buttn);
this.Controls.Remove(buttn2);
}
My question is I dont come out of the message boxes when I click message box button NO.I come out of the message box the first time I play the game,But If i play the game a second time,it takes me two clicks to come out of the Message box.If I play the game a third time,it takes me 3 clicks on either the Yes or NO button to come out of the Message Box.I hope you folks can help me.I had posted the same question before but without the code.Hope the code helps.
I think you may be subscribing to the
Click-event:in a place in the code where it’s called more than once, so when the button is clicked the MessageBox will be shown, and when the
buttn2_Clickevent handler (-your code that you posted) is finished – it will run again, showing another MessageBox, for as many times as the subscription (the “…+=…” above) was done.