protected override void OnMouseUp(MouseEventArgs e)
{
base.OnMouseUp(e);
if (!this.Created)
return;
if (e.Button == MouseButtons.Right) {
this.OnRightMouseUp(e);
return;
}
// What event should we listen for to start cell editing?
// ------------------------------------------------------
//
// We can't use OnMouseClick, OnMouseDoubleClick, OnClick, or OnDoubleClick
// since they are not triggered for clicks on subitems without Full Row Select.
//
// We could use OnMouseDown, but selecting rows is done in OnMouseUp. This means
// that if we start the editing during OnMouseDown, the editor will automatically
// lose focus when mouse up happens.
//
// Tell the world about a cell click. If someone handles it, don't do anything else
CellClickEventArgs args = new CellClickEventArgs();
this.BuildCellEvent(args, e.Location);
args.ClickCount = this.lastMouseDownClickCount;
this.OnCellClick(args);
if (args.Handled)
return;
// Did the user click a hyperlink?
if (this.UseHyperlinks &&
args.HitTest.HitTestLocation == HitTestLocation.Text &&
args.SubItem != null &&
!String.IsNullOrEmpty(args.SubItem.Url)) {
// We have to delay the running of this process otherwise we can generate
// a series of MouseUp events (don't ask me why)
this.BeginInvoke((MethodInvoker)delegate { this.ProcessHyperlinkClicked(args); });
}
// No one handled it so check to see if we should start editing.
if (!this.ShouldStartCellEdit(e))
return;
// We only start the edit if the user clicked on the image or text.
if (args.HitTest.HitTestLocation == HitTestLocation.Nothing)
return;
// We don't edit the primary column by single clicks -- only subitems.
if (this.CellEditActivation == CellEditActivateMode.SingleClick && args.ColumnIndex <= 0)
return;
// Don't start a cell edit operation when the user clicks on the background of a checkbox column -- it just looks wrong.
// If the user clicks on the actual checkbox, changing the checkbox state is handled elsewhere.
if (args.Column != null && args.Column.CheckBoxes)
return;
this.EditSubItem(args.Item, args.ColumnIndex);
}