日期:2014-05-17 浏览次数:21094 次
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 WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        private bool clicksignal = false;
        private bool codesignal = false;
        public Form1()
        {
            InitializeComponent();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            checkBox1.Checked = true;
        }
        private void button2_Click(object sender, EventArgs e)
        {
            checkBox1.Checked = false;
        }
        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            if (!clicksignal && !codesignal) 
            {
                codesignal = true;
                checkBox1.Checked = !checkBox1.Checked;
                codesignal = false;
            }
        }
        private void checkBox1_Click(object sender, EventArgs e)
        {
            clicksignal = true;
            checkBox1.Checked = !checkBox1.Checked;
            clicksignal = false;
        }
    }
}