exitornot.cs

来自「利用csharp实现的小程序」· CS 代码 · 共 54 行

CS
54
字号
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Suoxiao
{
    public partial class ExitOrNot : Form
    {
        public int flag = 0;
        public ExitOrNot(int flag)
        {
            InitializeComponent();
            this.flag = flag;
        }
        
        private void ExitOrNot_Load(object sender, EventArgs e)
        {
            this.radioButton1.Checked = false;
            this.radioButton2.Checked = false;
        }

        private void btnYes_Click(object sender, EventArgs e)
        {
            if (this.radioButton1.Checked == true)//退出系统
                flag = 1;
            if (this.radioButton2.Checked == true)//最小化到系统托盘
            {
                flag = 2;
            }
            if (this.flag == 0)
            {
                MessageBox.Show("请选择处理方式");
                return;
            }
            this.DialogResult = DialogResult.OK;
            this.Hide();
        }

        private void btnNo_Click(object sender, EventArgs e)
        {
            this.flag = 0;
            this.radioButton2.Checked = false;
            this.radioButton1.Checked = false ;
            
            this.DialogResult = DialogResult.Cancel ;
            this.Hide ();
        }

    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?