WINFROM Hint message box public class

Source: Internet
Author: User

1, the Winfrom project often uses the message prompt, Generally use the MessageBox.Show method, but like the error prompt, ask a hint, the warning hint is a bit complicated to write, and the following several hints have icons, but MessageBox.Show no icon, will affect the consistency of the project. So it encapsulates a common message prompt class Messagecommon

     Public Static classMessagecommon {/// <summary>        ///pop-up cue box by type/// </summary>        /// <param name= "type" >type war: Warning Que: asking err: Error Other default is message prompt</param>        /// <param name= "MSG" >message</param>         Public StaticDialogResult Showmassage (stringTypestringmsg) {                        Switch(type) { Case "War":                    returnMessageBox.Show (MSG,"Warning!", MessageBoxButtons.OK, messageboxicon.warning);  Case "que":                    returnMessageBox.Show (MSG,"do you want to continue?", Messageboxbuttons.okcancel, messageboxicon.question);  Case "Err":                    returnMessageBox.Show (MSG,"Error!", MessageBoxButtons.OK, Messageboxicon.error); default:                    returnMessageBox.Show (MSG,"Tips!", MessageBoxButtons.OK, messageboxicon.information); }        }        /// <summary>        ///warning Prompt/// </summary>        /// <param name= "MSG" >Message Content</param>        /// <returns></returns>         Public StaticDialogResult Showwar (stringmsg) {            returnShowmassage ("War", MSG); }        /// <summary>        ///Ask a hint/// </summary>        /// <param name= "MSG" >Message Content</param>        /// <returns>DialogResult.OK or DialogResult.Cancel</returns>         Public StaticDialogResult Showque (stringmsg) {            returnShowmassage ("que", MSG); }        /// <summary>        ///Error Hints/// </summary>        /// <param name= "MSG" >Message Content</param>        /// <returns></returns>         Public StaticDialogResult Showerr (stringmsg) {            returnShowmassage ("Err", MSG); }        /// <summary>        ///General Tips/// </summary>        /// <param name= "MSG" >Message Content</param>        /// <returns></returns>         Public StaticDialogResult Showinf (stringmsg) {            returnShowmassage ("inf", MSG); }    }

2. The following methods are used:

        //General Tips        Private voidButton1_Click (Objectsender, EventArgs e) {Messagecommon.showinf ("Tips!"); }        //Error Hints        Private voidButton2_Click (Objectsender, EventArgs e) {Messagecommon.showerr ("wrong operation!"); }        //warning Prompt        Private voidButton3_Click (Objectsender, EventArgs e) {Messagecommon.showwar ("No action!"); }        //Ask a hint        Private voidButton4_Click (Objectsender, EventArgs e) {            if(Messagecommon.showque ("does the operation have a risk of continuing?")==DialogResult.OK) {Messagecommon.showinf ("Determine"); }            Else{Messagecommon.showinf ("Cancel"); }        }

3. Operation:

4. Sample code:

http://download.csdn.net/detail/kehaigang29/8832703

WINFROM Hint message box public class

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.