Export (0) Print
Expand All
Expand Minimize

MessageBoxOptions Enumeration

Specifies options on a MessageBox.

This enumeration has a FlagsAttribute attribute that allows a bitwise combination of its member values.

[Visual Basic]
<Flags>
<Serializable>
Public Enum MessageBoxOptions
[C#]
[Flags]
[Serializable]
public enum MessageBoxOptions
[C++]
[Flags]
[Serializable]
__value public enum MessageBoxOptions
[JScript]
public
   Flags
 Serializable
enum MessageBoxOptions

Remarks

This enumeration is used by the MessageBox class.

Members

Member name Description Value
DefaultDesktopOnly The message box is displayed on the active desktop.

This constant is the same as ServiceNotification except that the system displays the message box only on the default desktop of the interactive window station.

131072
RightAlign The message box text is right-aligned. 524288
RtlReading Specifies that the message box text is displayed with right to left reading order. 1048576
ServiceNotification The message box is displayed on the active desktop.

The caller is a service notifying the user of an event. The function displays a message box on the current active desktop, even if there is no user logged on to the computer.

2097152

Example

[Visual Basic] 
Private Sub ValidateUserEntry2()


    ' Checks the value of the text.

    If ServerName.Text.Length = 0 Then

        ' Initializes variables to pass to the MessageBox.Show method.

        Dim Message As String = "You did not enter a server name. Cancel this operation?"
        Dim Caption As String = "No Server Name Specified"
        Dim Buttons As Integer = MessageBoxButtons.YesNo

        Dim Result As DialogResult

        'Displays a MessageBox using the Question icon and specifying the No button as the default.

        Result = MessageBox.Show(Me, Message, Caption, MessageBoxButtons.YesNo, _
            MessageBoxIcon.Question, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign)


        ' Gets the result of the MessageBox display.

        If Result = DialogResult.Yes Then

            ' Closes the parent form.

            Me.Close()

        End If

    End If

End Sub

[C#] 

    private void validateUserEntry2()
    {

        // Checks the value of the text.

        if(serverName.Text.Length == 0)
        {

            // Initializes the variables to pass to the MessageBox.Show method.

            string message = "You did not enter a server name. Cancel this operation?";
            string caption = "No Server Name Specified";
            MessageBoxButtons buttons = MessageBoxButtons.YesNo;
            DialogResult result;

            // Displays the MessageBox.

            result = MessageBox.Show(this, message, caption, buttons,
                MessageBoxIcon.Question, MessageBoxDefaultButton.Button1, 
                MessageBoxOptions.RightAlign);

            if(result == DialogResult.Yes)
            {

                // Closes the parent form.

                this.Close();

            }

        }

    }


[C++] 
private:
    void validateUserEntry2() {
        // Checks the value of the text.
        if (serverName->Text->Length == 0) {

            // Initializes the variables to pass to the MessageBox::Show method.
            String* message = S"You did not enter a server name. Cancel this operation?";
            String* caption = S"No Server Name Specified";
            MessageBoxButtons buttons = MessageBoxButtons::YesNo;
            System::Windows::Forms::DialogResult result;

            // Displays the MessageBox.
            result = MessageBox::Show(this, message, caption, buttons,
                MessageBoxIcon::Question, MessageBoxDefaultButton::Button1, 
                MessageBoxOptions::RightAlign);

            if (result == DialogResult::Yes) {
                // Closes the parent form.
                this->Close();
            }
        }
    }

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Namespace: System.Windows.Forms

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

Assembly: System.Windows.Forms (in System.Windows.Forms.dll)

See Also

System.Windows.Forms Namespace

Show:
© 2014 Microsoft