C#如何使用MessageBoxButtons / Icons修复此错误错误

问题描述 投票:-1回答:1

设计注册表单,我在MessageBoxButtons和MessageBoxIcon中添加时出现此错误。错误是“参数2:无法将'system.windows.forms.Messageboxicon'转换为'string'。错误所在的代码片段是:**

MessageBox.Show(“您已成功注册您的帐户”,MessageBoxIcon.Exclamation,MessageBoxButtons.OK);

**和这里一样:

MessageBox.Show(“请正确填写所有框”,MessageBoxIcon.Exclamation,MessageBoxButtons.OK);

当我删除Messageboxbutton /图标时,没有错误。这是我得到的:

        {
        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);


        }
c# messagebox
1个回答
0
投票

在这里你确实有正确的顺序,你忘了添加标题

MessageBox.Show("You have successfully registered your account","Your caption goes here", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

希望这可以帮助。

© www.soinside.com 2019 - 2024. All rights reserved.