Example #1
0
        private void chkHeader_OnCheckBoxClicked(object sender, DataGridViewCheckBoxHeaderCellEventArgs e)
        {
            foreach (EpisodeEntry entry in episodes)
            {
                entry.Enabled = e.Checked;
            }

            dataGridView.EndEdit();
            dataGridView.Refresh();
        }
        protected override void OnMouseClick(DataGridViewCellMouseEventArgs e)
        {
            Point p = new Point(e.X + _cellLocation.X, e.Y + _cellLocation.Y);

            if ((p.X >= checkBoxLocation.X) && (p.X <= checkBoxLocation.X + checkBoxSize.Width) &&
                (p.Y >= checkBoxLocation.Y) && (p.Y <= checkBoxLocation.Y + checkBoxSize.Height))
            {
                _checked = !_checked;
                DataGridViewCheckBoxHeaderCellEventArgs ev = new DataGridViewCheckBoxHeaderCellEventArgs(_checked);

                if (OnCheckBoxClicked != null)
                {
                    OnCheckBoxClicked(this, ev);
                    this.DataGridView.InvalidateCell(this);
                }
            }
            base.OnMouseClick(e);
        }