C. Call Message Dialog and get its return value

xiaoxiao2021-03-06  71

Unlike the VB, you can use MSGBox to get the return value of the message box. You need to use the DialogResult type variable to accept the return value of the message dialog from the MessageBox.show () method in C #. As for the return value of MessageBox.show () is YES, NO, OK or Cancel, you need to set it yourself in the show () method. The following sample code can be referred to: // Initializes The Variables To Pass to the messagebox.show method.

String message = "You Did NOTER A Server Name. CANCEL this Operation?"; string capen = "no server name specified"; messageboxbuttons button = messageboxbuttons.yesno; DialogResult Result;

// displays the messagebox.

Result = MessageBox.Show (this, Message, Caption, Buttons, MessageBoxicon.question, MessageBoxDefaultButton.Button1, MessageBoxOptions.Rightalign);

IF (Result == DialogResult.yes) {// do your action here.

转载请注明原文地址:https://www.9cbs.com/read-109479.html

New Post(0)