What buttons need to be displayed in a message box where OK and cancel are displayed
The code is as follows |
Copy Code |
MessageBoxButtons Messbutton = Messageboxbuttons.okcancel;
|
"Are you sure you want to exit?" "Is the display information for the dialog box," Exit System "is the title of the dialog box
By default, such as MessageBox.Show (Are you sure you want to exit?) ") displays only one OK button.
DialogResult dr = MessageBox.Show ("OK to exit?", "Exit System", Messbutton);
The code is as follows |
Copy Code |
if (dr = = DialogResult.OK)//If you click on the "OK" button { ...... } else//If you click the "Cancel" button { ...... } |
MessageBoxButtons specifies several constants to define which buttons will appear on MessageBox (from MSDN)
MessageBoxButtons Member:
Description of Member name
The Abortretryignore message box contains the abort, retry, and Ignore buttons.
The OK message box contains the OK button. Default
The Okcancel message box contains the OK and Cancel buttons. (as shown in the previous example)
The Retrycancel message box contains the retry and Cancel buttons.
The YESNO message box contains the Yes and no buttons.
Yesnocancel message box contains Yes, no and Cancel buttons
The function that is implemented is to pop up the error prompt dialog box when encountering an exception: three buttons in the window "OK" "Cancel" "Details"
The code is as follows |
Copy Code |
===================================== Use global events to catch ===================================== Using System; Using System.Windows.Forms; Using Microsoft.Win32;
Registers the global exception handler and throws the exception that is generated. Namespace Zhengzuo.csharpcode { Static Class Program {
<summary> The main entry point for the application. </summary> [STAThread] static void Main () { if (false = = Singleinstance.handlerunninginstance ()) { AppDomain.CurrentDomain.UnhandledException + = new Unhandledexceptioneventhandler (currentdomain_unhandledexception ); Application.ThreadException + = new System.Threading.ThreadExceptionEventHandler (application_threadexception); Systemevents.sessionending + = new Sessionendingeventhandler (systemevents_sessionending);
Application.enablevisualstyles (); Application.setcompatibletextrenderingdefault (FALSE); Application.Run (New FormMain ()); } }
static void Systemevents_sessionending (object sender, Sessionendingeventargs e) //{ throw new Exception ("the method or operation isn't implemented."); //}
static void Application_threadexception (object sender, System.Threading.ThreadExceptionEventArgs e) { throw new Exception ("the method or operation isn't implemented."); }
static void Currentdomain_unhandledexception (object sender, UnhandledExceptionEventArgs e) { throw new Exception ("the method or operation isn't implemented."); } } } |
winform,c# pop-up error prompt box, with Red Fork pop-up window, MessageBox.Show
Solutions
1.messagebox.show ("Two duplicate password inconsistencies", "Prompt", MessageBoxButtons.OK, Messageboxicon.error);