C# 4.0 向messagebox添加几个按钮
我将非常感谢你的回答。如何向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 {
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()放在按钮中,以便在执行所需操作后关闭表单