C# Winform MessageBox
MessageBox.Show(<字符串>Text, <字符串>Title, <整型>nType, MessageBoxIcon);
以上就是格式
第一个String 类型,表示提示框里面的 内容;
第二个String 类型,表示提示框的 表题;
第三个参数是整数类型,表示消息框的类型,一般都使用系统提供的几种类型。
第十个是提示框的 图标,提示、警告、错误等。
四个参数可以只填一个、两个、三个。。。
代码如下
MessageBox.Show("只有一个参数"); MessageBox.Show("只有两个参数", "两个参数"); MessageBox.Show("三个参数示例", "三个参数", MessageBoxButtons.OKCancel); MessageBox.Show("四个参数示例", "四个参数", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation);
结果如下图
它的类型也有很多种选择:
1 MessageBox.Show("消息内容", "返回值 确定1", MessageBoxButtons.OK, MessageBoxIcon.Question); 2 3 MessageBox.Show("消息内容", "返回值 确定1 取消2", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk); 4 5 MessageBox.Show("消息内容", "返回值 终止3 重试4 忽略5", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Error); 6 7 MessageBox.Show("消息内容", "返回值 是6 否7 取消2", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation); 8 9 MessageBox.Show("消息内容", "返回值 是6 否7", MessageBoxButtons.YesNo, MessageBoxIcon.Hand); 10 11 MessageBox.Show("消息内容", "返回值 重试4 取消2", MessageBoxButtons.RetryCancel, MessageBoxIcon.Information);
通过以上类型确定返回值,可以进一步做选择。
图标的几种样式有:
1 MessageBoxIcon.Question 2 3 MessageBoxIcon.Asterisk 4 5 MessageBoxIcon.Information 6 7 MessageBoxIcon.Error 8 9 MessageBoxIcon.Stop 10 11 MessageBoxIcon.Hand 12 13 MessageBoxIcon.Exclamation 14 15 MessageBoxIcon.Warning 16 17 MessageBoxIcon.None
当然还有其他的重载类型选择,这里就不一一介绍了,具体可以参考MSDN,这里面有其所有API的参考
本文参考:点这里
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· 字符编码:从基础到乱码解决
· Open-Sora 2.0 重磅开源!