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);
End of Code Snippet
Custom Fonts
Code Snippet
- MsgBox.Show(this, "Hello", "Caption Text", MessageBoxButtons.OK, MessageBoxIcon.Information, true, new Font("Verdana", 12f, FontStyle.Bold), Color.Red);
End of Code Snippet
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);
End of Code Snippet
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
End of Code Snippet
Download
Download MsgBox Here
No comments:
Post a Comment