MessageBoxOptions 列挙型
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
MessageBoxのオプションを指定します。
この列挙体は、メンバー値のビットごとの組み合わせをサポートしています。
public enum class MessageBoxOptions
[System.Flags]
public enum MessageBoxOptions
[<System.Flags>]
type MessageBoxOptions =
Public Enum MessageBoxOptions
- 継承
- 属性
フィールド
| 名前 | 値 | 説明 |
|---|---|---|
| DefaultDesktopOnly | 131072 | メッセージ ボックスがアクティブなデスクトップに表示されます。 この定数は |
| RightAlign | 524288 | メッセージ ボックスのテキストは右揃えです。 |
| RtlReading | 1048576 | メッセージ ボックスのテキストを右から左の読み取り順序で表示することを指定します。 |
| ServiceNotification | 2097152 | メッセージ ボックスがアクティブなデスクトップに表示されます。 呼び出し元は、イベントをユーザーに通知するサービスです。 Show は、コンピューターにログオンしているユーザーがいない場合でも、現在アクティブなデスクトップにメッセージ ボックスを表示します。 |
例
次の例では、MessageBox パラメーターを含むMessageBox.Showのオーバーロードでサポートされるオプションを使用してoptionsを表示する方法を示します。 文字列変数 ( 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 を渡すことができます。