0

私はあなたの答えに感謝します。メッセージボックスにボタンを追加するにはどうすればよいですか? 明確にするために、ボタンがあります。[保存] ボタンを押すと、「お願いします...」というメッセージ ボックスと、[キャンセル] と [続行] の両方のボタンが表示されます。

    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();            
        }

     }
4

1 に答える 1

1

はい/いいえ、キャンセルなどの標準メッセージを使用しない場合は、メッセージ ボックスのように見える新しい Windows フォームを簡単に作成できますカスタムボタン、好きなテキストを追加してから、表示するようにします:

NewForm customMessageBox = new NewForm();
customMesageBox.Show(this);

それでおしまい。目的のアクションが実行された後にフォームを閉じるには、ボタンに this.Close() を配置することを忘れないでください。

于 2013-10-06T13:05:29.190 に答える