Introduction
MsgBox is an enhanced solution to the in-built MessageBox class. It's designed so that the styles, features and behaviour mimic the in-built control with added features.
MsgBox allows a better Messagebox experience by allowing the following features:
- Do not display this message again
- Custom font styles and font colors
- Scrollbars for text which is too long
Using the code
MsgBox is used like a standard MessageBox object. There is a different return object which encapsulates the original DialogResult. This handles extra information which as whether the user clicked 'Do no display this message again'.
Simple Example
Code Snippet
MsgBox.Show(this, "Hello", "Caption Text", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
Custom Fonts
Code Snippet
MsgBox
.Show(this,
"
;Hello
"
;,
"
;Caption Text
"
;, MessageBoxButtons
.OK, MessageBoxIcon
.Information,
true,
new Font
("
;Verdana
"
;, 12f, FontStyle
.Bold), Color
.Red);
Long Text
Code Snippet
MsgBox
.Show(this,
"
;Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello
"
;,
"
;Caption Text
"
;, MessageBoxButtons
.OK, MessageBoxIcon
.Information,
true,
new Font
("
;Verdana
"
;, 40f, FontStyle
.Bold), Color
.Blue);
Handling the do not display message again checkbox
Code Snippet
DialogResultNew res = MsgBox.Show(this, "Hello", "Caption Text", MessageBoxButtons.OK);
if (res.DoNotDisplayMessageAgain) // Do something here
Download
Download MsgBox Here
History
v1.0 - Initial write-up