XmlMappedRange.BeforeRightClick Event


Occurs when an XmlMappedRange control is right-clicked, before the default right-click action.

Namespace:   Microsoft.Office.Tools.Excel
Assembly:  Microsoft.Office.Tools.Excel (in Microsoft.Office.Tools.Excel.dll)

event DocEvents_BeforeRightClickEventHandler BeforeRightClick

The following code demonstrates a handler for the BeforeRightClick event that cancels the right-click action in an XmlMappedRange. The event handler informs the user that right-clicking is not allowed for the XmlMappedRange, and then sets the Cancel parameter of the DocEvents_BeforeRightClickEventHandler event handler to true so that Microsoft Office Excel cancels the right-click action. This code example assumes that the current worksheet contains an XmlMappedRange named CustomerLastNameCell.

private void XmlMappedRange_BeforeRightClick()
    this.CustomerLastNameCell.BeforeRightClick += 
        new Excel.DocEvents_BeforeRightClickEventHandler(

void CustomerLastNameCell_BeforeRightClick(Excel.Range Target, 
    ref bool Cancel)
    MessageBox.Show("Right-clicking in this range " +
        " is not allowed.");
    Cancel = true;
Return to top