Exemple #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            //  this.Close();
            //   List<Form> forms = new List<Form>();

            //    if (Explication_Class.ShowMessage("Le texteeee", "Titre", MessageBoxButtons.OK, MessageBoxIcon.Question) == DialogResult.Yes)
            //   {
            // Explication_Class.ShowMessage("Le textt","titre", MessageBoxButtons.OK, MessageBoxIcon.Information);
            FrmMsgYesNo ff = new FrmMsgYesNo();

            ff.Show();
            // }
        }
        public static DialogResult ShowMessage(String msg, String caption, MessageBoxButtons btn, MessageBoxIcon icon)
        {
            DialogResult dgres = DialogResult.None;

            switch (btn)
            {
            case MessageBoxButtons.OK:

                using (frmmsgok frmok = new frmmsgok())
                {
                    frmok.Text   = caption;
                    frmok.mesage = msg;
                    switch (icon)
                    {
                    case MessageBoxIcon.Information:
                        frmok.msgicon = Properties.Resources.Exclamation_icon1; break;

                    case MessageBoxIcon.Question:
                        frmok.msgicon = Properties.Resources.Icon_Small_2x; break;
                    }
                    dgres = frmok.ShowDialog();
                } break;

            case MessageBoxButtons.YesNo:

                using (FrmMsgYesNo frmokYesNo = new FrmMsgYesNo())
                {
                    frmokYesNo.Text   = caption;
                    frmokYesNo.mesage = msg;
                    switch (icon)
                    {
                    case MessageBoxIcon.Information:
                        frmokYesNo.msgicon = Properties.Resources.Exclamation_icon1; break;

                    case MessageBoxIcon.Question:
                        frmokYesNo.msgicon = Properties.Resources.Icon_Small_2x;

                        break;
                    }
                    dgres = frmokYesNo.ShowDialog();
                }
                break;
            }
            return(dgres);
        }