Linux 拨号vps windows公众号手机端

C#中messagebox的用法有哪些

lewis 6年前 (2019-02-01) 阅读数 11 #程序编程
文章标签 messagebox

在C#中,可以使用MessageBox类来显示消息框。以下是MessageBox类常用的几个方法和用法:

  1. MessageBox.Show(string message):显示带有指定消息的消息框,并返回用户的操作结果。例如:
MessageBox.Show("Hello World");
  1. MessageBox.Show(string message, string caption):显示带有指定消息和标题的消息框,并返回用户的操作结果。例如:
MessageBox.Show("Hello World", "Greeting");
  1. MessageBox.Show(string message, string caption, MessageBoxButtons buttons):显示带有指定消息、标题和按钮的消息框,并返回用户的操作结果。例如:
MessageBox.Show("Are you sure?", "Confirmation", MessageBoxButtons.YesNo);
  1. MessageBox.Show(string message, string caption, MessageBoxButtons buttons, MessageBoxIcon icon):显示带有指定消息、标题、按钮和图标的消息框,并返回用户的操作结果。例如:
MessageBox.Show("Error occurred!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
  1. MessageBox.Show(string message, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton):显示带有指定消息、标题、按钮、图标和默认按钮的消息框,并返回用户的操作结果。例如:
MessageBox.Show("Save changes?", "Confirmation", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);

以上是MessageBox类的几个常用方法,可以根据需要选择合适的方法来显示消息框。

版权声明

本文仅代表作者观点,不代表米安网络立场。

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

热门