C#-MessageBox全部函数重载形式及举例
Form1.cs
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace MessageBoxTest1
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- /*About MessageBox.Show()*/
- //Show(String):消息框包含消息并返回结果
- //Show(String,String) 显示消息和标题栏
- //Show(Window,String) 在指定的窗口前面显示消息框,显示消息并返回结果
- //Show(String,String,BoxButton) 消息,标题栏,按钮,返回结果
- //Show(Window,String,String) 在指定窗口前面显示消息框,消息,标题栏
- //Show(String,String,MessageBoxButton,MessageBoxImage) 消息,标题栏,按钮,图标
- //Show (Window,String,String,MessageBoxButton)
- //Show(String,String,MessageBoxButton,MessageBoxImage)
- //Show(String,String,MessageBoxButton,MessageBoxImage,MessageBoxResult)
- //Show(Window,String,String,MessageBoxButton,MessageImage)
- //Show(String,String,MessageBoxButton,MessageBoxButton,MessageResult,MessageBoxOptions) 遵循指定项返回结果
- //Show(Window,String,String,
- /*end*/
- private void button1_Click(object sender, EventArgs e)
- {
- DialogResult dr = MessageBox.Show("消息信息", "标题", MessageBoxButtons.YesNoCancel);
- switch(dr)
- {
- case DialogResult.Cancel : MessageBox.Show("按下了Cancel"); break;
- case DialogResult.No: MessageBox.Show("按下了No"); break;
- case DialogResult.Yes: MessageBox.Show("按下了Yes!"); break;
- }
- }
- }
- }
Program.cs
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Windows.Forms;
- namespace MessageBoxTest1
- {
- static class Program
- {
- /// <summary>
- /// 应用程序的主入口点。
- /// </summary>
- [STAThread]
- static void Main()
- {
- Application.EnableVisualStyles();
- Application.SetCompatibleTextRenderingDefault(false);
- Application.Run(new Form1());
- }
- }
- }
Form1设计
- namespace MessageBoxTest1
- {
- partial class Form1
- {
- /// <summary>
- /// 必需的设计器变量。
- /// </summary>
- private System.ComponentModel.IContainer components = null;
- /// <summary>
- /// 清理所有正在使用的资源。
- /// </summary>
- /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
- protected override void Dispose(bool disposing)
- {
- if (disposing && (components != null))
- {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
- #region Windows 窗体设计器生成的代码
- /// <summary>
- /// 设计器支持所需的方法 - 不要
- /// 使用代码编辑器修改此方法的内容。
- /// </summary>
- private void InitializeComponent()
- {
- this.button1 = new System.Windows.Forms.Button();
- this.SuspendLayout();
- //
- // button1
- //
- this.button1.BackColor = System.Drawing.Color.Lime;
- this.button1.Location = new System.Drawing.Point(82, 39);
- this.button1.Name = "button1";
- this.button1.Size = new System.Drawing.Size(117, 23);
- this.button1.TabIndex = 1;
- this.button1.Text = "开始测试";
- this.button1.UseVisualStyleBackColor = false;
- this.button1.Click += new System.EventHandler(this.button1_Click);
- //
- // Form1
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(192)))));
- this.ClientSize = new System.Drawing.Size(296, 102);
- this.Controls.Add(this.button1);
- this.Name = "Form1";
- this.Text = "MessageBoxTest";
- this.ResumeLayout(false);
- }
- #endregion
- private System.Windows.Forms.Button button1;
- }
- }
C#-MessageBox全部函数重载形式及举例的更多相关文章
- 《从零开始学Swift》学习笔记(Day 7)——Swift 2.0中的print函数几种重载形式
原创文章,欢迎转载.转载请注明:关东升的博客 Swift 2.0中的print函数有4种重载形式: l print(_:).输出变量或常量到控制台,并且换行. l print(_:_:).输出 ...
- Javascript函数重载,存在呢—还是存在呢?
1.What's is 函数重载? );//Here is int 10 print("ten");//Here is string ten } 可以发现在C++中会根据参数的类型 ...
- c语言中,既然不支持函数重载,那么printf算怎么回事?在c语言中,它不就是被重载了吗?
这个问题问的不错.其实printf不是重载,c语言不支持函数重载 这句话是对的.printf函数是通过变长参数表实现的.你可以查看一下printf的函数原型声明.printf函数的实现在不同的机器上是 ...
- C++学习27 用全局函数重载运算符
运算符重载函数既可以声明为类的成员函数,也可以声明为所有类之外的全局函数. 运算符重载函数作为类的成员函数 将运算符重载函数声明为类的成员函数时,二元运算符的参数只有一个,一元运算符不需要参数.之所以 ...
- C++学习笔记之模板(1)——从函数重载到函数模板
一.函数重载 因为函数重载比较容易理解,并且非常有助于我们理解函数模板的意义,所以这里我们先来用一个经典的例子展示为什么要使用函数重载,这比读文字定义有效的多. 现在我们编写一个交换两个int变量值得 ...
- C++学习笔记(八):函数重载、函数指针和函数对象
函数重载 函数重载是指在同一作用域内,可以有一组具有相同函数名,不同参数列表的函数,这组函数被称为重载函数.重载函数通常用来命名一组功能相似的函数,这样做减少了函数名的数量,避免了名字空间的污染,对于 ...
- C++函数重载遇到了函数默认参数情况
一.C++中的函数重载 什么是函数重载? 我的理解是: (1)用一个函数名定义不同的函数: (2)函数名和不同参数搭配时函数会有不同的含义: 举例说明: #include <stdio.h> ...
- const和非const函数重载
成员函数后面加const,表示在该函数中不能对类的数据成员进行改变,比如下面的代码: #include <stdio.h> class A { private: mutable int a ...
- 小猪猪C++笔记基础篇(六)参数传递、函数重载、函数指针、调试帮助
小猪猪C++笔记基础篇(六) ————参数传递.函数重载.函数指针.调试帮助 关键词:参数传递.函数重载.函数指针.调试帮助 因为一些事情以及自己的懒惰,大概有一个星期没有继续读书了,已经不行了,赶紧 ...
随机推荐
- Linux (x86) Exploit 开发系列教程之六(绕过ASLR - 第一部分)
转:https://bbs.pediy.com/thread-217390.htm 前提条件: 经典的基于堆栈的缓冲区溢出 虚拟机安装:Ubuntu 12.04(x86) 在以前的帖子中,我们看到了攻 ...
- HTML中的ul, ol,li , dl,dt, dd标签
ul: unordered lists ol: ordered lists li: Lists ol 有序列表. <ol><li>……</li><li> ...
- java console 到文件
System.setOut(new PrintStream(new FileOutputStream("c:\\temp\\test1.txt"))); System.out.pr ...
- javascript的优缺点和内置对象
1)优点:简单易用,与Java有类似的语法,可以使用任何文本编辑工具编写,只需要浏览器就可执行程序,并且事先不用编译,逐行执行,无需进行严格的变量声明,而且内置大量现成对象,编写少量程序可以完成目标: ...
- C和指针之学习笔记(4)
第9章 字符串 字符串的输入与输出 int ch; char strings[80]; FILE *input; (1)scanf(“%c”,&ch); printf(“%c \n” ...
- 【BZOJ 4555】 4555: [Tjoi2016&Heoi2016]求和 (NTT)
4555: [Tjoi2016&Heoi2016]求和 Time Limit: 40 Sec Memory Limit: 128 MBSubmit: 315 Solved: 252 Des ...
- BZOJ1019 汉诺塔
定义f[i][j]为将i柱上的j个盘挪走(按优先级)的步数 p[i][j]为将i柱上的j个盘按优先级最先挪至何处 首先考虑一定p[i][j]!=i 设初始为a柱,p[i][j-1]为b柱 考虑两种情况 ...
- [BZOJ4012][HNOI2015]开店(动态点分治,树链剖分)
4012: [HNOI2015]开店 Time Limit: 70 Sec Memory Limit: 512 MBSubmit: 2168 Solved: 947[Submit][Status] ...
- PAT甲级1089. Insert or Merge
PAT甲级1089. Insert or Merge 题意: 根据维基百科: 插入排序迭代,消耗一个输入元素每次重复,并增加排序的输出列表.每次迭代,插入排序从输入数据中删除一个元素,在排序列表中找到 ...
- 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 ...