Name
MessageBox
Synopsis
This class provides a simple means to display a modal pop-up box with
a title, message, and icon, and obtain some basic Yes/No, OK/Cancel
information from the user. It is essentially a wrapper around the
Win32 MessageBox() method.
You can Show() a message, which returns the
DialogResult indicating which button the end user
clicked. When showing the message, you can specify the title and body
text, the MessageBoxButtons to show (and which
button is the MessageBoxDefaultButton), the
MessageBoxIcon, and some
MessageBoxOptions that deal with right-to-left
mode, multiple desktop alignment, and alignment.
Don’t forget that popping up a message box is highly
intrusive, forcibly interrupting a users workflow. You might consider
ErrorProvider, or even a
ToolTip, as a better way of notifying the user of
problems.
public class MessageBox { // Public Static Methods public static DialogResult Show(IWin32Window owner, string text); public static DialogResult Show(IWin32Window owner, string text, string caption); public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons); public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon); public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton); public static DialogResult Show(IWin32Window owner, string ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access