MessageBoxOptions Výčet
Definice
Důležité
Některé informace platí pro předběžně vydaný produkt, který se může zásadně změnit, než ho výrobce nebo autor vydá. Microsoft neposkytuje žádné záruky, výslovné ani předpokládané, týkající se zde uváděných informací.
Určuje možnosti v MessageBox.
Tento výčet podporuje bitové kombinace hodnot jeho členů.
public enum class MessageBoxOptions
[System.Flags]
public enum MessageBoxOptions
[<System.Flags>]
type MessageBoxOptions =
Public Enum MessageBoxOptions
- Dědičnost
- Atributy
Pole
| Name | Hodnota | Description |
|---|---|---|
| DefaultDesktopOnly | 131072 | Okno se zprávou se zobrazí na aktivní ploše. Tato konstanta je podobná s tím rozdílem |
| RightAlign | 524288 | Text pole zprávy je zarovnaný doprava. |
| RtlReading | 1048576 | Určuje, že text pole zprávy se zobrazí s pořadím čtení zprava doleva. |
| ServiceNotification | 2097152 | Okno se zprávou se zobrazí na aktivní ploše. Volající je služba, která uživatele upozorní na událost. Show zobrazí okno se zprávou na aktuální aktivní ploše, i když k počítači není přihlášen žádný uživatel. |
Příklady
Následující příklad ukazuje, jak zobrazit MessageBox s možnostmi podporovanými přetíženími MessageBox.Show , které zahrnují options parametr. Po ověření, že řetězcová proměnná je ServerNameprázdná, zobrazí se v příkladu MessageBox ikona pole s otázkou, která uživateli nabídne možnost zrušit operaci. Příklad používá člen výčtu MessageBoxOptions.RightAlign k zarovnání textu k pravému okraji dialogového okna.
Show Pokud je vrácená hodnota metody vyhodnocena jako DialogResult.Yes, formulář, který zobrazil, MessageBox je uzavřen.
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
Poznámky
Tento výčet je používán MessageBox třídou.
Pokud nechcete při volání metod MessageBoxzadat argument , můžete místo toho předat hodnotu 0.