共用方式為


XmlMappedRange.BeforeRightClick Event

Definition

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

public:
 event Microsoft::Office::Interop::Excel::DocEvents_BeforeRightClickEventHandler ^ BeforeRightClick;
event Microsoft.Office.Interop.Excel.DocEvents_BeforeRightClickEventHandler BeforeRightClick;
member this.BeforeRightClick : Microsoft.Office.Interop.Excel.DocEvents_BeforeRightClickEventHandler 
Event BeforeRightClick As DocEvents_BeforeRightClickEventHandler 

Event Type

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.

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;
}
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

Applies to