Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 4.0 向messagebox添加几个按钮_C# 4.0 - Fatal编程技术网

C# 4.0 向messagebox添加几个按钮

C# 4.0 向messagebox添加几个按钮,c#-4.0,C# 4.0,我将非常感谢你的回答。如何向messagebox添加按钮?很明显,我有一个按钮,当我按下保存按钮时,我会看到一个消息框,上面写着:“请…”和两个按钮,取消并继续 private void button1_Click(object sender, EventArgs e) { MessageBox.Show("Please fill all..."); // I like to add to this messagebox buttons {

我将非常感谢你的回答。如何向messagebox添加按钮?很明显,我有一个按钮,当我按下保存按钮时,我会看到一个消息框,上面写着:“请…”和两个按钮,取消并继续

    private void button1_Click(object sender, EventArgs e)
    {
        MessageBox.Show("Please fill all..."); // I like to add to this messagebox buttons

        {
        SqlConnection con = new SqlConnection("Data Source=.\\sqlexpress;Initial Catalog=VirtualSalesFair;Integrated Security=True");
        con.Open();
        SqlCommand sc = new SqlCommand("Insert into Empty value('" + textBox1.Text + "'," + textBox2.Text + ",'" + textBox3.Text + "','" + textBox4.Text + "','" + textBox5.Text + "','" + textBox6.Text + "','" + textBox7.Text + "','" + textBox8.Text + "','" +textBox9.Text +"',"+textBox10.Text +");", con);
        int o=sc.ExecuteNonQuery();
        MessageBox.Show(o+ ":Record has been inserted");
        con.Close();            
        }

     }

如果您不习惯使用“是/否”、“取消”等标准消息。。。(),您可以简单地创建一个新的windows窗体,它看起来像消息框。添加自定义按钮、您喜欢的文本,然后让其显示:

NewForm customMessageBox = new NewForm();
customMesageBox.Show(this);
就这样。 不要忘记将此.Close()放在按钮中,以便在执行所需操作后关闭表单