Nevron Open Vision Documentation
Message Box

The message box is a common type of modal dialog that displays information to the user. It may also request the user to select one of several options by clicking a button. Nevron Open Vision lets you easily create and show message boxes through the static Show method of the NMessageBox class. The different overloads of the method lets you configure all aspects of the message box - its text, title, buttons and icon.

The code below demonstrates how to show a message box that asks the user whether he wants to save the changes of a document and how to handle the Closed event of the message box to perform the proper actions based on the button the user has clicked:

Message Box Example
Copy Code
NMessageBox.Show("Do you want to save the changes?", "Question", ENMessageBoxButtons.YesNoCancel, ENMessageBoxIcon.Question,
    delegate(NMessageBox msgBox, ENWindowResult result)
    {
        if (result == ENWindowResult.Yes)
        {
            // The user has clicked the 'Yes' button
        }
        else if (result == ENWindowResult.No)
        {
            // The user has clicked the 'No' button
        }
        else
        {
            // The user has clicked the 'Cancel' button or has closed the message box
        }
    }
);

This code will show the following message box to the user:

By default the first button of the message box is the default one, i.e. focused by default, so that you can use the Space or Enter keyboard key to click it. If you want to change that, you should pass one of the three values of the ENMessageBoxDefaultButton enumeration to the message box Show method.

Send Feedback