c# - C# 如何使用我的 MessageBoxButtons/Icons 修复此错误错误
问题描述
设计注册表单,添加 MessageBoxButtons 和 MessageBoxIcon 时出现此错误。错误是“参数2:无法将'system.windows.forms.Messageboxicon'转换为'string'。错误所在的代码是这样的:**
MessageBox.Show("您的账号注册成功", MessageBoxIcon.Exclamation, MessageBoxButtons.OK);
** 以及这里:
MessageBox.Show("请正确填写所有方框", MessageBoxIcon.Exclamation, MessageBoxButtons.OK);
当我删除 Messageboxbutton/icon 时,没有错误。这是我得到的:
{
MyConnections.insert.CommandText = "INSERT Customer(EmailAddress,Firstname,Surname,Password)VALUES('" + txtEmail.Text + "','" + txtFirst.Text + "','" + txtSur.Text + "','" + txtPassword.Text + "')";
MyConnections.insert.Connection = MyConnections.Customer;
MyConnections.Customer.Open();
MyConnections.insert.ExecuteNonQuery();
MyConnections.Customer.Close();
if (txtFirst.Text.Length > 0 && txtSur.Text.Length > 0 && txtEmail.Text.Length > 0 && txtPassword.Text.Length > 0 && txtConfirmPass.Text.Length > 0)
{
MessageBox.Show("You have successfully registered your account", MessageBoxIcon.Exclamation, MessageBoxButtons.OK);
}
else
{
MessageBox.Show("Please fill in all of the boxes correctly", MessageBoxIcon.Exclamation, MessageBoxButtons.OK);
}
解决方案
在这里,您确实有正确的顺序,但您忘记添加标题
MessageBox.Show("You have successfully registered your account","Your caption goes here", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
希望这可以帮助。
推荐阅读
- html - 尝试增加 Div 高度时,它不起作用。帮助表示赞赏
- c# - 抽象基类列表仅返回基类的属性
- core-data - 如何在使用 MVVM 的同时使用 SwiftUI 实现核心数据关系
- javascript - 如何使用 Jest 单元测试触发 transitionend
- database - 数据库如何提供原子性?
- node.js - 不和谐.js | 图片分离/非嵌入
- r - 有条件地向列添加 12 小时
- sql - 使用显式值进行 BigQuery 合并
- javascript - 如何在 javascript 中读取二进制音频文件?
- python - 在我的函数修复中,2 个嵌套的 while 循环的时间复杂度如何为 o(N)?