Show メソッド (IWin32Window)
例外メッセージ ボックスを、親ウィンドウの中央にモーダル ダイアログ ボックスとして表示します。
名前空間: Microsoft.SqlServer.MessageBox
アセンブリ: Microsoft.ExceptionMessageBox (Microsoft.ExceptionMessageBox.dll)
構文
'宣言
Public Function Show ( _
owner As IWin32Window _
) As DialogResult
'使用
Dim instance As ExceptionMessageBox
Dim owner As IWin32Window
Dim returnValue As DialogResult
returnValue = instance.Show(owner)
public DialogResult Show(
IWin32Window owner
)
public:
DialogResult Show(
IWin32Window^ owner
)
member Show :
owner:IWin32Window -> DialogResult
public function Show(
owner : IWin32Window
) : DialogResult
パラメーター
- owner
型: System.Windows.Forms. . :: . .IWin32Window
例外メッセージ ボックスの親ウィンドウです。
戻り値
型: System.Windows.Forms. . :: . .DialogResult
ユーザーによってクリックされたボタンの DialogResult です。
説明
Buttons が Custom である場合、Show により常に Cancel が返されます。ユーザーによりクリックされたボタンを判別するには、CustomDialogResult を使用します。
Owner に NULL 値が指定されると、Windows タスク バーに例外メッセージ ボックスが表示されます。代わりに親ウィンドウ オブジェクトを渡すようお勧めします。
使用例
try
{
// Do something that may generate an exception.
throw new ApplicationException("An error has occured");
}
catch (ApplicationException ex)
{
// Define a new top-level error message.
string str = "The action failed.";
// Add the new top-level message to the handled exception.
ApplicationException exTop = new ApplicationException(str, ex);
exTop.Source = this.Text;
// Show an exception message box with an OK button (the default).
ExceptionMessageBox box = new ExceptionMessageBox(exTop);
box.Show(this);
}
Try
' Do something that may generate an exception.
Throw New ApplicationException("An error has occured")
Catch ex As ApplicationException
' Define a new top-level error message.
Dim str As String = "The action failed."
' Add the new top-level message to the handled exception.
Dim exTop As ApplicationException = New ApplicationException(str, ex)
exTop.Source = Me.Text
' Show an exception message box with an OK button (the default).
Dim box As ExceptionMessageBox = New ExceptionMessageBox(exTop)
box.Show(Me)
End Try