Advertisement

11.19.2007 at 10:28AM PST, ID: 22970839
[x]
Attachment Details

C# using Message.box == DialogResult.Yes and handling the button selection

Asked by Karl66 in C# Programming Language, Programming Languages

Tags: yes, box, message

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.Button2);

            if (MessageBox.Show("Select yes or No.", "Yes or No", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == 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.Button2) == DialogResult.No);
            {
                MessageBox.Show("You chose No.");
                // I tried break, return and this.Close() here but I do not like the results.
            }
        }Start Free Trial
 
Loading Advertisement...
 
[+][-]11.19.2007 at 10:34AM PST, ID: 20314269

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: C# Programming Language, Programming Languages
Tags: yes, box, message
Sign Up Now!
Solution Provided By: jaime_olivares
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628