Form1.cs

  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. namespace MessageBoxTest1
  10. {
  11. public partial class Form1 : Form
  12. {
  13. public Form1()
  14. {
  15. InitializeComponent();
  16. }
  17. /*About MessageBox.Show()*/
  18. //Show(String):消息框包含消息并返回结果
  19. //Show(String,String) 显示消息和标题栏
  20. //Show(Window,String) 在指定的窗口前面显示消息框,显示消息并返回结果
  21. //Show(String,String,BoxButton)  消息,标题栏,按钮,返回结果
  22. //Show(Window,String,String) 在指定窗口前面显示消息框,消息,标题栏
  23. //Show(String,String,MessageBoxButton,MessageBoxImage) 消息,标题栏,按钮,图标
  24. //Show (Window,String,String,MessageBoxButton)
  25. //Show(String,String,MessageBoxButton,MessageBoxImage)
  26. //Show(String,String,MessageBoxButton,MessageBoxImage,MessageBoxResult)
  27. //Show(Window,String,String,MessageBoxButton,MessageImage)
  28. //Show(String,String,MessageBoxButton,MessageBoxButton,MessageResult,MessageBoxOptions)  遵循指定项返回结果
  29. //Show(Window,String,String,
  30. /*end*/
  31. private void button1_Click(object sender, EventArgs e)
  32. {
  33. DialogResult dr = MessageBox.Show("消息信息", "标题", MessageBoxButtons.YesNoCancel);
  34. switch(dr)
  35. {
  36. case DialogResult.Cancel : MessageBox.Show("按下了Cancel"); break;
  37. case DialogResult.No: MessageBox.Show("按下了No"); break;
  38. case DialogResult.Yes: MessageBox.Show("按下了Yes!"); break;
  39. }
  40. }
  41. }
  42. }

Program.cs

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Windows.Forms;
  5. namespace MessageBoxTest1
  6. {
  7. static class Program
  8. {
  9. /// <summary>
  10. /// 应用程序的主入口点。
  11. /// </summary>
  12. [STAThread]
  13. static void Main()
  14. {
  15. Application.EnableVisualStyles();
  16. Application.SetCompatibleTextRenderingDefault(false);
  17. Application.Run(new Form1());
  18. }
  19. }
  20. }

Form1设计

    1. namespace MessageBoxTest1
    2. {
    3. partial class Form1
    4. {
    5. /// <summary>
    6. /// 必需的设计器变量。
    7. /// </summary>
    8. private System.ComponentModel.IContainer components = null;
    9. /// <summary>
    10. /// 清理所有正在使用的资源。
    11. /// </summary>
    12. /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
    13. protected override void Dispose(bool disposing)
    14. {
    15. if (disposing && (components != null))
    16. {
    17. components.Dispose();
    18. }
    19. base.Dispose(disposing);
    20. }
    21. #region Windows 窗体设计器生成的代码
    22. /// <summary>
    23. /// 设计器支持所需的方法 - 不要
    24. /// 使用代码编辑器修改此方法的内容。
    25. /// </summary>
    26. private void InitializeComponent()
    27. {
    28. this.button1 = new System.Windows.Forms.Button();
    29. this.SuspendLayout();
    30. //
    31. // button1
    32. //
    33. this.button1.BackColor = System.Drawing.Color.Lime;
    34. this.button1.Location = new System.Drawing.Point(82, 39);
    35. this.button1.Name = "button1";
    36. this.button1.Size = new System.Drawing.Size(117, 23);
    37. this.button1.TabIndex = 1;
    38. this.button1.Text = "开始测试";
    39. this.button1.UseVisualStyleBackColor = false;
    40. this.button1.Click += new System.EventHandler(this.button1_Click);
    41. //
    42. // Form1
    43. //
    44. this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
    45. this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    46. this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(192)))));
    47. this.ClientSize = new System.Drawing.Size(296, 102);
    48. this.Controls.Add(this.button1);
    49. this.Name = "Form1";
    50. this.Text = "MessageBoxTest";
    51. this.ResumeLayout(false);
    52. }
    53. #endregion
    54. private System.Windows.Forms.Button button1;
    55. }
    56. }

C#-MessageBox全部函数重载形式及举例的更多相关文章

  1. 《从零开始学Swift》学习笔记(Day 7)——Swift 2.0中的print函数几种重载形式

    原创文章,欢迎转载.转载请注明:关东升的博客 Swift 2.0中的print函数有4种重载形式: l   print(_:).输出变量或常量到控制台,并且换行. l   print(_:_:).输出 ...

  2. Javascript函数重载,存在呢—还是存在呢?

    1.What's is 函数重载? );//Here is int 10 print("ten");//Here is string ten } 可以发现在C++中会根据参数的类型 ...

  3. c语言中,既然不支持函数重载,那么printf算怎么回事?在c语言中,它不就是被重载了吗?

    这个问题问的不错.其实printf不是重载,c语言不支持函数重载 这句话是对的.printf函数是通过变长参数表实现的.你可以查看一下printf的函数原型声明.printf函数的实现在不同的机器上是 ...

  4. C++学习27 用全局函数重载运算符

    运算符重载函数既可以声明为类的成员函数,也可以声明为所有类之外的全局函数. 运算符重载函数作为类的成员函数 将运算符重载函数声明为类的成员函数时,二元运算符的参数只有一个,一元运算符不需要参数.之所以 ...

  5. C++学习笔记之模板(1)——从函数重载到函数模板

    一.函数重载 因为函数重载比较容易理解,并且非常有助于我们理解函数模板的意义,所以这里我们先来用一个经典的例子展示为什么要使用函数重载,这比读文字定义有效的多. 现在我们编写一个交换两个int变量值得 ...

  6. C++学习笔记(八):函数重载、函数指针和函数对象

    函数重载 函数重载是指在同一作用域内,可以有一组具有相同函数名,不同参数列表的函数,这组函数被称为重载函数.重载函数通常用来命名一组功能相似的函数,这样做减少了函数名的数量,避免了名字空间的污染,对于 ...

  7. C++函数重载遇到了函数默认参数情况

    一.C++中的函数重载 什么是函数重载? 我的理解是: (1)用一个函数名定义不同的函数: (2)函数名和不同参数搭配时函数会有不同的含义: 举例说明: #include <stdio.h> ...

  8. const和非const函数重载

    成员函数后面加const,表示在该函数中不能对类的数据成员进行改变,比如下面的代码: #include <stdio.h> class A { private: mutable int a ...

  9. 小猪猪C++笔记基础篇(六)参数传递、函数重载、函数指针、调试帮助

    小猪猪C++笔记基础篇(六) ————参数传递.函数重载.函数指针.调试帮助 关键词:参数传递.函数重载.函数指针.调试帮助 因为一些事情以及自己的懒惰,大概有一个星期没有继续读书了,已经不行了,赶紧 ...

随机推荐

  1. Linux (x86) Exploit 开发系列教程之六(绕过ASLR - 第一部分)

    转:https://bbs.pediy.com/thread-217390.htm 前提条件: 经典的基于堆栈的缓冲区溢出 虚拟机安装:Ubuntu 12.04(x86) 在以前的帖子中,我们看到了攻 ...

  2. HTML中的ul, ol,li , dl,dt, dd标签

    ul: unordered lists ol: ordered lists li: Lists ol 有序列表. <ol><li>……</li><li> ...

  3. java console 到文件

    System.setOut(new PrintStream(new FileOutputStream("c:\\temp\\test1.txt"))); System.out.pr ...

  4. javascript的优缺点和内置对象

    1)优点:简单易用,与Java有类似的语法,可以使用任何文本编辑工具编写,只需要浏览器就可执行程序,并且事先不用编译,逐行执行,无需进行严格的变量声明,而且内置大量现成对象,编写少量程序可以完成目标: ...

  5. C和指针之学习笔记(4)

    第9章 字符串 字符串的输入与输出 int  ch;  char strings[80];  FILE *input; (1)scanf(“%c”,&ch);   printf(“%c \n” ...

  6. 【BZOJ 4555】 4555: [Tjoi2016&Heoi2016]求和 (NTT)

    4555: [Tjoi2016&Heoi2016]求和 Time Limit: 40 Sec  Memory Limit: 128 MBSubmit: 315  Solved: 252 Des ...

  7. BZOJ1019 汉诺塔

    定义f[i][j]为将i柱上的j个盘挪走(按优先级)的步数 p[i][j]为将i柱上的j个盘按优先级最先挪至何处 首先考虑一定p[i][j]!=i 设初始为a柱,p[i][j-1]为b柱 考虑两种情况 ...

  8. [BZOJ4012][HNOI2015]开店(动态点分治,树链剖分)

    4012: [HNOI2015]开店 Time Limit: 70 Sec  Memory Limit: 512 MBSubmit: 2168  Solved: 947[Submit][Status] ...

  9. PAT甲级1089. Insert or Merge

    PAT甲级1089. Insert or Merge 题意: 根据维基百科: 插入排序迭代,消耗一个输入元素每次重复,并增加排序的输出列表.每次迭代,插入排序从输入数据中删除一个元素,在排序列表中找到 ...

  10. Wide-range regulator delivers 12V, 3A output from 16 to 100V source

    Synchronous buck regulators offer high efficiency and are popular in applications in which available ...