Create a Modeless Messagebox

后端 未结 7 1466
难免孤独
难免孤独 2021-02-07 01:00

How might one go about creating a Modeless MessageBox? Do I have to just create my own Windows Form class and use that? If so, is there an easy way of adding a warning icon (rat

相关标签:
7条回答
  • 2021-02-07 01:46

    Short of writing the code, you could create a small form that in the constructor does the following

    • Takes a parameter string as the message to display
    • Fills up a label on the form with this string
    • Loads an icon with one of the following (pass in an Enum to the constructor)
      • SystemIcons.Application
      • SystemIcons.Asterix
      • SystemIcons.Error
      • SystemIcons.Exclamation
      • SystemIcons.Hand
      • SystemIcons.Information
      • SystemIcons.Question
      • SystemIcons.Shield
      • SystemIcons.Warning
      • SystemIcons.WinLogo
    • Calls Show() which will cause it to be a modal dialog

    If you really wanted, you could listen to an event that is fired when the OK button is pushed.

    0 讨论(0)
提交回复
热议问题