DialogResult Enumeráció

Definíció

Egy párbeszédpanel visszatérési értékét jelző azonosítókat ad meg.

public enum class DialogResult
[System.Runtime.InteropServices.ComVisible(true)]
public enum DialogResult
[<System.Runtime.InteropServices.ComVisible(true)>]
type DialogResult = 
Public Enum DialogResult
Öröklődés
DialogResult
Attribútumok

Mezők

Name Érték Description
None 0

Nothing a párbeszédpanelről adja vissza. Ez azt jelenti, hogy a modális párbeszédpanel továbbra is fut.

OK 1

A párbeszédpanel visszatérési OK értéke (általában az OK címkével ellátott gombról érkezik).

Cancel 2

A párbeszédpanel visszatérési értéke (általában Cancel a Mégse gombról érkezik).

Abort 3

A párbeszédpanel visszatérési értéke (általában Abort egy megszakítás címkével ellátott gombról küldve).

Retry 4

A párbeszédpanel visszatérési Retry értéke (általában az Újrapróbálkozás gombról küldve).

Ignore 5

A párbeszédpanel visszatérési értéke (általában Ignore a Figyelmen kívül hagyás gombról érkezik).

Yes 6

A párbeszédpanel visszatérési értéke (általában Yes az Igen címkével ellátott gombról érkezik).

No 7

A párbeszédpanel visszatérési No értéke (általában a Nem címkével ellátott gombról érkezik).

Példák

Az alábbi példakód bemutatja, hogyan jeleníthet meg egy MessageBox olyan beállítást, amelyet a rendszer túlterhelése Showtámogat. Miután ellenőrizte, ServerNamehogy egy sztringváltozó üres-e, a példában megjelenik egy MessageBox, amely lehetőséget kínál a felhasználónak a művelet megszakítására. Ha a Show metódus visszatérési értéke Igen értékre van kiértékelve, az azt megjelenítő MessageBox űrlap bezárul.

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

Megjegyzések

A Button.DialogResult tulajdonság és a metódus ezt az Form.ShowDialog enumerálást használja.

A következőre érvényes:

Lásd még