WizardPage.ShowMessage メソッド
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
指定したテキストを使用するメッセージ ボックスを表示します。
オーバーロード
ShowMessage(String) |
指定したテキストを使用するメッセージ ボックスを表示します。 |
ShowMessage(String, MessageBoxButtons, MessageBoxIcon, MessageBoxDefaultButton) |
指定したテキスト、ボタン セット、シンボル、および既定のボタンを使用するメッセージ ボックスを表示します。 |
ShowMessage(String)
指定したテキストを使用するメッセージ ボックスを表示します。
protected:
void ShowMessage(System::String ^ text);
protected void ShowMessage (string text);
member this.ShowMessage : string -> unit
Protected Sub ShowMessage (text As String)
パラメーター
- text
- String
表示するメッセージ。
注釈
このオーバーロードされたメソッドは、列挙体によって定義される [OK] ボタンのみを含むメッセージ ボックスを System.Windows.Forms.MessageBoxButtons 表示します。
適用対象
ShowMessage(String, MessageBoxButtons, MessageBoxIcon, MessageBoxDefaultButton)
指定したテキスト、ボタン セット、シンボル、および既定のボタンを使用するメッセージ ボックスを表示します。
protected:
System::Windows::Forms::DialogResult ShowMessage(System::String ^ text, System::Windows::Forms::MessageBoxButtons buttons, System::Windows::Forms::MessageBoxIcon icon, System::Windows::Forms::MessageBoxDefaultButton defaultButton);
protected System.Windows.Forms.DialogResult ShowMessage (string text, System.Windows.Forms.MessageBoxButtons buttons, System.Windows.Forms.MessageBoxIcon icon, System.Windows.Forms.MessageBoxDefaultButton defaultButton);
member this.ShowMessage : string * System.Windows.Forms.MessageBoxButtons * System.Windows.Forms.MessageBoxIcon * System.Windows.Forms.MessageBoxDefaultButton -> System.Windows.Forms.DialogResult
Protected Function ShowMessage (text As String, buttons As MessageBoxButtons, icon As MessageBoxIcon, defaultButton As MessageBoxDefaultButton) As DialogResult
パラメーター
- text
- String
メッセージ ボックスに表示するメッセージ。
- buttons
- MessageBoxButtons
MessageBoxButtons 値のいずれか 1 つ。
- icon
- MessageBoxIcon
MessageBoxIcon 値のいずれか 1 つ。
- defaultButton
- MessageBoxDefaultButton
MessageBoxDefaultButton 値のいずれか 1 つ。
戻り値
DialogResult 値のいずれか 1 つ。
例
次の例では、 オーバーロードを ShowMessage(String, MessageBoxButtons, MessageBoxIcon, MessageBoxDefaultButton) 示します。 次の使用例は、[ はい ] ボタンと [いいえ ] ボタンと情報記号を含むメッセージ ボックスを表示し、操作を取り消す機会をユーザーに提供します。 このコード例は、WizardPage クラスのために提供されている大規模な例の一部です。
// Customize the CanNavigateNext property. This property
// is set to false until the user is validated.
private void button1_Click(object sender, EventArgs e)
{
// Perform user validation checks. If this is a valid
// user move to the next page. If the user is not a valid
// user, exit the application.
// User validation.
string text = "Did the user pass validation?";
MessageBoxButtons buttons = MessageBoxButtons.YesNo;
MessageBoxIcon icon = MessageBoxIcon.Information;
MessageBoxDefaultButton defaultButton = MessageBoxDefaultButton.Button2;
DialogResult result = ShowMessage(text, buttons, icon, defaultButton);
if (result == DialogResult.No)
{
Application.Exit();
}
else
{
_canNavigateNext = true;
this.UpdateWizard();
ShowHelp();
}
}
protected new DialogResult ShowMessage(string text,
MessageBoxButtons buttons,
MessageBoxIcon icon,
MessageBoxDefaultButton defaultButton)
{
return base.ShowMessage(text + " Yes or No.", buttons, icon, defaultButton);
}
注釈
このメソッドを使用すると、カスタム メソッドを作成できます ShowMessage 。 このメソッドの戻り System.Windows.Forms.DialogResult 値を確認して、ユーザーのアクションを確認できます。