Message Box Class
using System; using System.Collections.Generic; using System.Text; using System.Windows.Forms; namespace messageBox { public static class MsgBox { // Displays a Confirm type message box // parameter name="sMsg" is The message you want to display public static bool Confirm(string sMsg) { return Confirm("Confirm :", sMsg); } public static bool Confirm(string sTitle, string sMsg) { DialogResult ret = MessageBox.Show(sMsg, sTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question); return (ret == DialogResult.Yes); } //--------------------------------------------------------------------- // Displays a Error type message box // parameter name="sMsg" is The message you want to display public static void Error(string sMsg) { Error("Error :", sMsg); } public static void Error(string sTitle, string sMsg) { MessageBox.Show(sMsg, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); } //--------------------------------------------------------------------- // Displays a Warning type message box // parameter name="sMsg" is The message you want to display public static void Warning(string sMsg) { Warning("", sMsg); } //--------------------------------------------------------------------- // Displays a Warning type message box // parameter name="sCaption" is Name of Application or Class or Method // parameter name="sMsg" is The message you want to display public static void Warning(string sCaption, string sMsg) { if (sCaption.Length == 0) sCaption = "Warning"; MessageBox.Show(sMsg, sCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning); } //--------------------------------------------------------------------- // Displays a Information type message box // parameter name="sMsg" is The message you want to display public static void Info(string sMsg) { Info("", sMsg); } //--------------------------------------------------------------------- // Displays a Information type message box // parameter name="sCaption" is Name of Application or Class or Method // parameter name="sMsg" is The message you want to display public static void Info(string sCaption, string sMsg) { if (sCaption.Length == 0) sCaption = "Information"; MessageBox.Show(sMsg, sCaption, MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
By Mohd Zulkamal
NOTE : – If You have Found this post Helpful, I will appreciate if you can Share it on Facebook, Twitter and Other Social Media Sites. Thanks =)
0 comments:
Post a Comment