Karl66
asked on
C# using Message.box == DialogResult.Yes and handling the button selection
C# VS 2008/2005 - Dianlogue box button selection. Simple.
I have a YES or NO Dialogue box and when the users selects YES or NO they get another dialogue box informing them of their selection. Simple yea? Mine is not working it lets me click the main message box YES or NO twice and then gives me a YES possibly NO. Looked so straight forward.
Thoughts?
private void btnDisplayMessageBox_Click (object sender, EventArgs e)
{
MessageBox.Show("Select yes or No.", "Yes or No", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Bu tton2);
if (MessageBox.Show("Select yes or No.", "Yes or No", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Bu tton2) == DialogResult.Yes);
{
MessageBox.Show("You chose Yes.");
// I tried break, return and this.Close() here but I do not like the results.
}
if (MessageBox.Show("Select yes or No.", "Yes or No", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Bu tton2) == DialogResult.No);
{
MessageBox.Show("You chose No.");
// I tried break, return and this.Close() here but I do not like the results.
}
}
I have a YES or NO Dialogue box and when the users selects YES or NO they get another dialogue box informing them of their selection. Simple yea? Mine is not working it lets me click the main message box YES or NO twice and then gives me a YES possibly NO. Looked so straight forward.
Thoughts?
private void btnDisplayMessageBox_Click
{
MessageBox.Show("Select yes or No.", "Yes or No", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Bu
if (MessageBox.Show("Select yes or No.", "Yes or No", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Bu
{
MessageBox.Show("You chose Yes.");
// I tried break, return and this.Close() here but I do not like the results.
}
if (MessageBox.Show("Select yes or No.", "Yes or No", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Bu
{
MessageBox.Show("You chose No.");
// I tried break, return and this.Close() here but I do not like the results.
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.