Reputation: 45
I will be grateful for your answer. How i am adding buttons to the messagebox? To be clearly, I have a button, when i press on the Save button i get a messagebox with this text: "Please..." and both those buttons, Cancel and Proceed.
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();
}
}
Upvotes: 0
Views: 163
Reputation: 4199
If you do not wont to use standard messages like Yes/No, Cancel, etc... (see list here), you can simpy create a new windows forms, that will look like message box. Add custom buttons, the text you like and then you just make it to show:
NewForm customMessageBox = new NewForm();
customMesageBox.Show(this);
thats it. Do not forget to put this.Close() in the buttons to close the form after the desired action is performed.
Upvotes: 1