Пример #1
0
        /// <summary>
        /// 勾选行
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ch_OnCheckBoxClicked(object sender, datagridviewCheckboxHeaderEventArgs e)
        {
            if (dgv1 == null || dgv1.Rows.Count == 0)
            {
                return;
            }

            foreach (DataGridViewRow dr in dgv1.Rows)
            {
                dr.Cells[0].Value = e.CheckedState;
            }

            dgv1.EndEdit();
        }
Пример #2
0
 private void ch_OnCheckBoxClicked(object sender, datagridviewCheckboxHeaderEventArgs e)
 {
     dataGridViewMaster.EndEdit();
     foreach (DataGridViewRow dgvRow in this.dataGridViewMaster.Rows)
     {
         if (e.CheckedState)
         {
             dgvRow.Cells[0].Value = true;
         }
         else
         {
             dgvRow.Cells[0].Value = false;
         }
     }
 }
Пример #3
0
            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;

                    datagridviewCheckboxHeaderEventArgs ex = new datagridviewCheckboxHeaderEventArgs();
                    ex.CheckedState = _checked;
                    ex.ColumnIndex  = e.ColumnIndex;
                    object sender = new object();

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