XmlMappedRange.BeforeRightClick Event (2007 System)

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

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

Syntax

'Declaration
Public Event BeforeRightClick As DocEvents_BeforeRightClickEventHandler
'Usage
Dim instance As XmlMappedRange 
Dim handler As DocEvents_BeforeRightClickEventHandler 

AddHandler instance.BeforeRightClick, handler
public event DocEvents_BeforeRightClickEventHandler BeforeRightClick
public:
 event DocEvents_BeforeRightClickEventHandler^ BeforeRightClick {
    void add (DocEvents_BeforeRightClickEventHandler^ value);
    void remove (DocEvents_BeforeRightClickEventHandler^ value);
}
JScript does not support events.

Examples

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.

Sub CustomerLastNameCell_BeforeRightClick(ByVal Target As Excel.Range, _
    ByRef Cancel As Boolean) Handles CustomerLastNameCell.BeforeRightClick
    MsgBox("Right-clicking in this range is not allowed.")
    Cancel = True 
End Sub
private void XmlMappedRange_BeforeRightClick()
{
    this.CustomerLastNameCell.BeforeRightClick += 
        new Excel.DocEvents_BeforeRightClickEventHandler(
        CustomerLastNameCell_BeforeRightClick);
}

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

.NET Framework Security

See Also

Reference

XmlMappedRange Class

XmlMappedRange Members

Microsoft.Office.Tools.Excel Namespace