Method:
I. Using a window to view the formclosing event
2. In the event method, the prompt indicates the
1. Using a window to view the formclosing event
// The closing event of the window. This event was triggered before the window was closed.
This. formclosing + = new system. Windows. Forms. formclosingeventhandler (this. memberformclosing );
2. In the event method, the callback prompt is used as the callback. /// <Summary>
/// Method for sending window-specific reference data
/// </Summary>
/// <Param name = "sender"> </param>
/// <Param name = "E"> Formclosingeventargs class metric data, providing information for the formclosing event </Param>
Private Void Memberformclosing ( Object Sender, formclosingeventargs E)
{
// Get the value returned after the single-dataset operation is performed in the message box. (In practice, the dialogresult operation is used to return the dialogresult message, which indicates which sort operations are performed separately)
Dialogresult key = MessageBox. Show (
" Are you sure want to quit " ,
" Confim " ,
Messageboxbuttons. yesno,
Messageboxicon. Question
);
// Determine whether or not the reading window is required
E. Cancel = (Key = Dialogresult. No );
}
Description:
This method is used to display a message box, requiring users to determine whether they exit the application.Program. The message box contains the "yes" and "no" Two listeners and one question.
Where:
Formclosingeventargs: provides information for the formclosing event.
Dialogresult: Specifies the timeout value of the target user. Members:
Member name |
Description |
abort |
the response value of the target speaker is abort ( generally, it is marked as [ abort ] ) . |
cancel |
the response value of the target speaker is cancel ( generally, it is marked as [ cancel ] ) . |
ignore |
the response value of the target speaker is ignore ( generally, it is marked as [ ignore ] ) . |
NO |
the response value of the target speaker is NO ( generally, it is marked as [ NO ] ) . |
none |
caller callback nothing . This indicates the write Response (Modal) the caller cannot parse the line. |
OK |
the response value of the corresponding vertex is OK ( generally, it is marked as [ confirm ] ) . |
retry |
the response value of the target speaker is retry ( generally, it is marked as [ duplicate ] ) . |
Yes |
the response value of the target speaker is Yes ( generally, it is marked as [ Yes ] ) . |
MessageBox: indicates the principal information that can contain text, tokens, and notifications, and indicate the user's token.
The metric data includes:
MessageBox. Show (
Iwin32window owner,
String Text,
String Caption,
Messageboxbuttons buttons,
Messageboxicon icon,
Messageboxdefaultbutton defaultbutton,
Messageboxoptions options,
String Helpfilepath,
Helpnavigator Navigator,
Object Param
)
Data Description: Owner: iwin32window. In this example, there will be a response to the caller.
Text: Text to be displayed in the plain text.
Caption: indicates the text to be displayed in the subject column of the principal.
Buttons: One of the messageboxbuttons values, which specifies which listeners are to be displayed in the principal parameter.
Icon: One of the messageboxicon values. Specify the value to be displayed in the parameter.
Defaultbutton: One of the messageboxdefaultbutton values, which specifies the parameter value of the parameter.
Options: One of the messageboxoptions values, which specifies the information used by the caller and the selection of the parameter. If you want to use the reset parameter 0 .
Helpfilepath: the user clicks [description] the path and name of the statement shown by the hour.
Navigator: One of the helpnavigator values.
Param: indicates the data ID of the subject to be presented when the user presses [description.
Returned value: One of the dialogresult values.
Dialogresult key = MessageBox. show (...) method: obtain the value returned after a single listener in the message box is pressed. (actually, it is returned as a dialogresult worker, which indicates which listeners are ordered)
E. Cancel = (Key = dialogresult. No)
Cancel indicates whether to cancel the event. If it is set to true, the window will not be closed. When the value is false, the window will be closed when an event ends.