C#中messagebox的用法有哪些


在C#中,可以使用MessageBox类来显示消息框。以下是MessageBox类常用的几个方法和用法:
1. MessageBox.Show(string message):显示带有指定消息的消息框,并返回用户的操作结果。例如:
```csharp
MessageBox.Show("Hello World");
```
2. MessageBox.Show(string message, string caption):显示带有指定消息和标题的消息框,并返回用户的操作结果。例如:
```csharp
MessageBox.Show("Hello World", "Greeting");
```
3. MessageBox.Show(string message, string caption, MessageBoxButtons buttons):显示带有指定消息、标题和按钮的消息框,并返回用户的操作结果。例如:
```csharp
MessageBox.Show("Are you sure?", "Confirmation", MessageBoxButtons.YesNo);
```
4. MessageBox.Show(string message, string caption, MessageBoxButtons buttons, MessageBoxIcon icon):显示带有指定消息、标题、按钮和图标的消息框,并返回用户的操作结果。例如:
```csharp
MessageBox.Show("Error occurred!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
```
5. MessageBox.Show(string message, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton):显示带有指定消息、标题、按钮、图标和默认按钮的消息框,并返回用户的操作结果。例如:
```csharp
MessageBox.Show("Save changes?", "Confirmation", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
```
以上是MessageBox类的几个常用方法,可以根据需要选择合适的方法来显示消息框。


上一篇:java中treeset的用法有哪些

下一篇:thinkphp安装到虚拟主机的方法是什么


Copyright © 2002-2019 测速网 www.inhv.cn 皖ICP备2023010105号
测速城市 测速地区 测速街道 网速测试城市 网速测试地区 网速测试街道
温馨提示:部分文章图片数据来源与网络,仅供参考!版权归原作者所有,如有侵权请联系删除!

热门搜索 城市网站建设 地区网站制作 街道网页设计 大写数字 热点城市 热点地区 热点街道 热点时间 房贷计算器