自定义弹框提示信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ZB.QueueSys.UC
{
    public partial class ShowMessage : Form
    {
        public ShowMessage()
        {
            InitializeComponent();
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            //if (MessageBox.Show("确认退出?", "提示", MessageBoxButtons.YesNo,
            //   MessageBoxIcon.Information) == DialogResult.Yes)
            //{
            //Application.ExitThread();
            this.Close();
            // }
        }

        /// <summary>
        /// 显示消息提示界面
        /// </summary>
        /// <param name="title">窗体标题</param>
        /// <param name="message">消息提示内容</param>
        /// <param name="isDisplayCancel">是否显示取消按钮</param>
        /// <returns></returns>
        public DialogResult Show(string title, string message, bool isDisplayCancel = false)
        {
            this.btnCancel.Visible = isDisplayCancel;
            this.lblTitle.Text = title;
            this.lblMessage.Text = message;

            DialogResult result = this.ShowDialog();
            //if (result == DialogResult.OK) Application.ExitThread();
            return result;
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.OK;
            this.Close();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
            this.Close();
        }

    }
}

  运行效果:

猜你喜欢

转载自www.cnblogs.com/YYkun/p/8981098.html