Here is some code that only switches on the first click if it hits the checkbox (not just the cell)
protected override void Edit(System.Windows.Forms.CurrencyManager source, int rowNum, System.Drawing.Rectangle bounds, bool readOnly, string instantText, bool cellIsVisible)
{
saveValue = (bool) base.GetColumnValueAtRow(source, rowNum);
if(Control.MouseButtons == MouseButtons.Left)
{
Point mousePos = this.DataGridTableStyle.DataGrid.PointToClient(Control.MousePosition);
DataGrid dg = this.DataGridTableStyle.DataGrid;
Rectangle rect = dg.GetCellBounds(dg.CurrentCell);
//define the checkbox hit size somehow
Size checkiconsize = new Size(20, 20);//SystemInformation.SmallIconSize; //however you want to define the hit-area
//assume checkbox is centered
rect = new Rectangle(rect.Left + (rect.Width- checkiconsize.Height) / 2,
rect.Top + (rect.Height - checkiconsize.Height) / 2,
checkiconsize.Width, checkiconsize.Height);
if(rect.Contains(mousePos))
{
saveValue = !saveValue;
base.SetColumnValueAtRow(source, rowNum, saveValue);
//fire the event
if(BoolValueChanged != null)
{
BoolValueChangedEventArgs e = new BoolValueChangedEventArgs(rowNum, _column, saveValue);
BoolValueChanged(this, e);
}
}
lockValue = true;
beingEdited = true;
saveRow = rowNum;
base.Edit(source, rowNum, bounds, readOnly, instantText, cellIsVisible);
}
}