CommonDialog.ShowDialog 方法

定义

显示通用对话框。Displays a common dialog.

重载

ShowDialog()

显示通用对话框。Displays a common dialog.

ShowDialog(Window)

显示通用对话框。Displays a common dialog.

注解

ShowDialog在调用RunDialog之前对所有常见对话框执行初始化任务。ShowDialog performs initialization tasks for all common dialogs before calling RunDialog. 由于RunDialog需要所有者窗口, ShowDialog因此尝试按以下优先级顺序分配一个窗口:Since RunDialog requires an owner window, ShowDialog attempts to assign one in the following order of precedence:

  • 当前应用程序的活动窗口The current application's active window.

  • 当前应用程序的停车窗口The current application's parking window.

  • 内部生成的隐藏窗口。An internally generated hidden window.

ShowDialog()

显示通用对话框。Displays a common dialog.

public:
 virtual Nullable<bool> ShowDialog();
[System.Security.SecurityCritical]
public virtual Nullable<bool> ShowDialog ();
abstract member ShowDialog : unit -> Nullable<bool>
override this.ShowDialog : unit -> Nullable<bool>
Public Overridable Function ShowDialog () As Nullable(Of Boolean)

返回

如果用户单击显示的对话框(例如 OpenFileDialogSaveFileDialog)的“确定”按钮,则返回 true;否则返回 falseIf the user clicks the OK button of the dialog that is displayed (e.g. OpenFileDialog, SaveFileDialog), true is returned; otherwise, false.

属性

注解

ShowDialog在调用RunDialog之前对所有常见对话框执行初始化任务。ShowDialog performs initialization tasks for all common dialogs before calling RunDialog.

在当前实现中, 派生类OpenFileDialog (和SaveFileDialog) 将仅返回truefalseIn the current implementation, the derived classes (OpenFileDialog and SaveFileDialog) will only return true or false.

安全性

UIPermission
在不引发异常的情况下执行此方法。to execute this method without raising of an exception. 关联的枚举:AllWindowsAssociated enumeration: AllWindows

ShowDialog(Window)

显示通用对话框。Displays a common dialog.

public:
 Nullable<bool> ShowDialog(System::Windows::Window ^ owner);
[System.Security.SecurityCritical]
public Nullable<bool> ShowDialog (System.Windows.Window owner);
member this.ShowDialog : System.Windows.Window -> Nullable<bool>
Public Function ShowDialog (owner As Window) As Nullable(Of Boolean)

参数

owner
Window

对话框所在的窗口的句柄。Handle to the window that owns the dialog.

返回

如果用户单击显示的对话框(例如 OpenFileDialogSaveFileDialog)的“确定”按钮,则返回 true;否则返回 falseIf the user clicks the OK button of the dialog that is displayed (e.g. OpenFileDialog, SaveFileDialog), true is returned; otherwise, false.

属性

注解

ShowDialog在调用RunDialog之前对所有常见对话框执行初始化任务。ShowDialog performs initialization tasks for all common dialogs before calling RunDialog. 此外, 将为最终显示的对话框分配一个所有者窗口, 该窗口是由owner参数指定的。Additionally, the dialog that is eventually shown is assigned an owner window, which is specified by the owner parameter.

在当前实现中, 派生类OpenFileDialog (和SaveFileDialog) 将仅返回truefalseIn the current implementation, the derived classes (OpenFileDialog and SaveFileDialog) will only return true or false.

安全性

UIPermission
在不引发异常的情况下执行此方法。to execute this method without raising of an exception. 关联的枚举:AllWindowsAssociated enumeration: AllWindows

另请参阅

适用于