MessageBox - ahatornn/clforms GitHub Wiki
MessageBox
ClForms.Elements.MessageBox
Displays a message window which presents a message to the user. It is a modal window, blocking other actions in the application until the user closes it. A MessageBox can contain text, buttons, and symbols that inform and instruct the user
Returns
One of the DialogResult values
Examples
The following code example instantiates and creates a MessageBox with caption, text, icon and buttons.
…
MessageBox.Show("Warning caption is here",
"This is a message box with the specified text, caption, icon and buttons…",
MessageBoxIcon.Warning,
MessageBoxButtons.YesNoCancel);
…
You can find more examples of using the CheckBoxGroup in this project
Remarks
A message box is a prefabricated modal dialog box that displays a text message to a user. You show a message box by calling the static Show method of the MessageBox class. The text message that is displayed is the string argument that you pass to Show.
You can also use a message box to ask a user a question. The user answers by clicking one of several buttons that you specify to display by using the MessageBoxButtons enumeration. You can pass this enumeration to several overloads of the Show method. The default value of the MessageBoxButtons enumeration is OK.
You can determine which button a user clicks by examining the value that Show returns. The return value is a value of the DialogResult enumeration, where each value equates to one of the buttons that a message box can display. The default value for message box is OK because OK is the default message box button. However, some overloads of the Show method enable you to provide a different DialogResult default value.
Message boxes can communicate information and can ask questions that have varying degrees of importance. Message boxes use icons to indicate importance. For example, icons can indicate whether the message is informational, is a warning, or is important. The MessageBoxIcon enumeration encapsulates the set of possible message box icons. By default, a message box does not display an icon. However, you can pass a MessageBoxIcon value to one of several Show method overloads in order to specify that the message box includes an icon.
Parameters
| Name | Description |
|---|---|
| caption | The text to display in the title bar of the message box |
| message | The text to display in the message box |
| messageIcon | One of the MessageBoxIcon values that specifies which icon to display in the message box |
| buttons | One of the MessageBoxButtons values that specifies which buttons to display in the message box |
Methods
// Displays a message box in front of the specified object and with the specified text.
// It also contains error icon
ShowError(string message)
// Displays a message box in front of the specified object and with the specified caption
// and text. It also contains error icon
ShowError(string caption, string message)
// Displays a message box in front of the specified object and with the specified caption
// and exception
ShowError(string caption, Exception exception)
// Displays a message box in front of the specified object and with the specified text
Show(string message)
// Displays a message box in front of the specified object and with the specified caption
// and text
Show(string caption, string message)
// Displays a message box in front of the specified object and with the specified caption,
// text and buttons
Show(string caption, string message, MessageBoxButtons buttons)
// Displays a message box in front of the specified object and with the specified text,
// icon and buttons
Show(string message, MessageBoxIcon messageIcon, MessageBoxButtons buttons)
// Displays a message box in front of the specified object and with the specified caption,
// text, icon and buttons
Show(string caption, string message, MessageBoxIcon messageIcon, MessageBoxButtons buttons)