DialogResult 列舉

定義

指定識別項以指示對話方塊的傳回值。

public enum class DialogResult
[System.Runtime.InteropServices.ComVisible(true)]
public enum DialogResult
public enum DialogResult
[<System.Runtime.InteropServices.ComVisible(true)>]
type DialogResult = 
type DialogResult = 
Public Enum DialogResult
繼承
DialogResult
屬性

欄位

Abort 3

對話方塊傳回值是 Abort (通常由標記為 [中止] 的按鈕傳回)。

Cancel 2

對話方塊傳回值是 Cancel (通常由標記為 [取消] 的按鈕傳回)。

Continue 11

對話方塊傳回值為 Continue (通常從標示為 Continue) 的按鈕傳送。

Ignore 5

對話方塊傳回值是 Ignore (通常由標記為 [忽略] 的按鈕傳回)。

No 7

對話方塊傳回值是 No (通常由標記為 [否] 的按鈕傳回)。

None 0

對話方塊傳回 Nothing。 這表示強制回應 (Modal) 對話方塊繼續執行。

OK 1

對話方塊的傳回值是 OK (通常由標記為 [確定] 的按鈕傳回)。

Retry 4

對話方塊傳回值是 Retry (通常由標記為 [重試] 的按鈕傳回)。

TryAgain 10

對話方塊傳回值為 [再試 (通常會從標示為 [再試) ] 的按鈕傳送。

Yes 6

對話方塊傳回值是 Yes (通常由標記為 [是] 的按鈕傳回)。

範例

下列程式碼範例示範如何使用 這個 多載 Show 所支援的選項來顯示 MessageBox 。 確認字串變數 ServerName 為 空白之後,此範例會顯示 , MessageBox 為使用者提供取消作業的選項。 Show如果方法的傳回值評估為 [是],則會關閉顯示 MessageBox 的表單。

private:
   void validateUserEntry5()
   {
      // 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 );
         if ( result == ::DialogResult::Yes )
         {
            // Closes the parent form.
            this->Close();
         }
      }
   }
private void validateUserEntry5()
{

    // 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);

        if(result == DialogResult.Yes)
        {

            // Closes the parent form.

            this.Close();
        }
    }
}
Private Sub ValidateUserEntry5()

    ' 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)

        ' 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

備註

屬性 Button.DialogResult 和 方法會 Form.ShowDialog 使用此列舉。

適用於

另請參閱