MessageBoxOptions 列舉

定義

指定 MessageBox 上的選項。

此列舉支援其成員值的位元組合。

public enum class MessageBoxOptions
[System.Flags]
public enum MessageBoxOptions
[<System.Flags>]
type MessageBoxOptions = 
Public Enum MessageBoxOptions
繼承
MessageBoxOptions
屬性

欄位

DefaultDesktopOnly 131072

訊息方塊顯示在使用中的桌面上。 此常數類似於 ServiceNotification,只不過系統只會在互動式視窗工作站的預設桌面上顯示訊息方塊。 顯示訊息方塊的應用程式會失去焦點,而且會以不使用視覺化樣式的方式顯示該訊息方塊。 如需詳細資訊,請參閱 使用視覺化樣式轉譯控制項

RightAlign 524288

訊息方塊靠右對齊。

RtlReading 1048576

指定訊息方塊文字是以從右向左的讀取順序顯示。

ServiceNotification 2097152

訊息方塊顯示在使用中的桌面上。 呼叫者是一個會通知使用者發生事件的服務。 即使沒有任何使用者登入電腦,Show 也會在目前的作用中桌面上顯示訊息方塊。

範例

下列範例示範如何使用 包含 options 參數之 MessageBox.Show 多載所支援的選項來顯示 MessageBox 。 確認字串變數 ServerName 為 空白之後,此範例會顯示 MessageBox 具有問題方塊圖示的 ,為使用者提供取消作業的選項。 此範例會 MessageBoxOptions.RightAlign 使用 列舉成員,將文字對齊對話方塊的右邊緣。 Show如果方法的傳回值評估為 DialogResult.Yes ,則會關閉顯示 MessageBox 的表單。

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;
         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();
         }
      }
   }

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();
        }
    }
}
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 = System.Windows.Forms.DialogResult.Yes Then

            ' Closes the parent form.

            Me.Close()

        End If

    End If

End Sub

備註

這項列舉供 MessageBox 類別使用。

如果您不想在 上 MessageBox 呼叫 方法時指定引數,您可以改為傳入 0。

適用於