c#-winform-pop-up popup-How do I know which button the user clicked on?

Source: Internet
Author: User

MessageBox.Show () has 21 overloads

Popular pop-up popup box

1, a parameter, pop-up window only one option

2, three parameters, the first parameter is to set the text content of the popup message box, the second parameter is to set the text displayed in the title bar of the pop-up window; The third parameter is which buttons are displayed in the specified message box

Like what:

(Lee Brainstorming Lxc)

So how do you know if a user clicked "OK" or "Cancel"?

MessageBox.Show () returns a DialogResult value

Private voidButton1_Click (Objectsender, EventArgs e) {DialogResult Dr= MessageBox.Show ("I'm a small plane! ","I can fly! ", Messageboxbuttons.okcancel); if(dr = =DialogResult.OK) {button1. Text="OK button"; }            Else if(dr = =dialogresult.cancel) {button1. Text="It's canceled! "; }        }
receive the button that the user clicked

c#-winform-pop-up popup-How do I know which button the user clicked on?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.