【问题标题】:Function : system.windows.messagebox功能:系统.windows.消息框
【发布时间】:2023-01-26 04:58:29
【问题描述】:

是否可以在消息框 (system.windows.messagebox) 上输入除 yes no 以外的其他值? 有没有可能没有“不”。 我会看到类似的东西: “应用程序将重新启动,准备好后按 [yes, ok,**]”

谢谢

【问题讨论】:

  • 您好,是否可以在消息框 (system.windows.messagebox) 上输入除 yes no 以外的其他值?有没有可能没有“不”。我会看到类似这样的内容:“应用程序将重新启动,准备好后按 [yes, ok,**]” Thks
  • 您目前使用什么代码?
  • here 记录了您可以使用标准消息框的消息框按钮的风格。

标签: powershell


【解决方案1】:

[System.Windows.Messagebox] 类型有多个重载版本的 show 方法,允许设置各种选项。

这是一个使用 show 版本的简单示例,它接受一个表示消息文本的字符串、一个表示消息标题的字符串和一个表示要在消息框中放置哪些按钮的 [System.Windows.MessageBoxButton]

[System.Windows.MessageBox]::Show('This is my message text','Message Title',[System.Windows.MessageBoxButton]::Ok)

您可以查看各种类型的System.Windows.MessageBoxButtons,看看哪种最适合您的情况。

【讨论】:

    【解决方案2】:

    显示所有重载:

    Add-Type -assemblyname PresentationFramework
    [Windows.MessageBox]::Show
    
    OverloadDefinitions
    -------------------
    static System.Windows.MessageBoxResult Show(string messageBoxText, string caption, System.Windows.MessageBoxButton button, System.Windows.MessageBoxImage icon, System.Windows.MessageBoxResult
    defaultResult, System.Windows.MessageBoxOptions options)
    static System.Windows.MessageBoxResult Show(string messageBoxText, string caption, System.Windows.MessageBoxButton button, System.Windows.MessageBoxImage icon, System.Windows.MessageBoxResult
    defaultResult)
    static System.Windows.MessageBoxResult Show(string messageBoxText, string caption, System.Windows.MessageBoxButton button, System.Windows.MessageBoxImage icon)
    static System.Windows.MessageBoxResult Show(string messageBoxText, string caption, System.Windows.MessageBoxButton button)
    static System.Windows.MessageBoxResult Show(string messageBoxText, string caption)
    static System.Windows.MessageBoxResult Show(string messageBoxText)
    static System.Windows.MessageBoxResult Show(System.Windows.Window owner, string messageBoxText, string caption, System.Windows.MessageBoxButton button, System.Windows.MessageBoxImage icon,
    System.Windows.MessageBoxResult defaultResult, System.Windows.MessageBoxOptions options)
    static System.Windows.MessageBoxResult Show(System.Windows.Window owner, string messageBoxText, string caption, System.Windows.MessageBoxButton button, System.Windows.MessageBoxImage icon,
    System.Windows.MessageBoxResult defaultResult)
    static System.Windows.MessageBoxResult Show(System.Windows.Window owner, string messageBoxText, string caption, System.Windows.MessageBoxButton button, System.Windows.MessageBoxImage icon)
    static System.Windows.MessageBoxResult Show(System.Windows.Window owner, string messageBoxText, string caption, System.Windows.MessageBoxButton button)
    static System.Windows.MessageBoxResult Show(System.Windows.Window owner, string messageBoxText, string caption)
    static System.Windows.MessageBoxResult Show(System.Windows.Window owner, string messageBoxText)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-11-21
      • 1970-01-01
      • 1970-01-01
      • 2021-05-28
      • 1970-01-01
      • 1970-01-01
      • 2012-02-02
      • 1970-01-01
      相关资源
      最近更新 更多