protected virtual bool HandleContextMenu(ref Message m)
{
// Don't try to handle context menu commands at design time.
if (this.DesignMode)
return false;
// If the context menu command was generated by the keyboard, LParam will be -1.
// We don't want to process these.
if (m.LParam == this.minusOne)
return false;
// If the context menu came from somewhere other than the header control,
// we also don't want to ignore it
if (m.WParam != this.HeaderControl.Handle)
return false;
// OK. Looks like a right click in the header
if (!this.PossibleFinishCellEditing())
return true;
int columnIndex = this.HeaderControl.ColumnIndexUnderCursor;
return this.HandleHeaderRightClick(columnIndex);
}