ListObject.BeforeRightClick Event

 

Occurs when the ListObject 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 example creates a ListObject and a BeforeRightClick event handler. When the list object is right-clicked, a message is displayed that indicates whether the list object is bound to data.

This version is for a document-level customization.

Microsoft.Office.Tools.Excel.ListObject list3;
private void ListObject_BeforeRightClick()
{
    list3 = this.Controls.AddListObject(
        this.Range["A1", "C4"], "list3");
    list3.BeforeRightClick += new 
        Microsoft.Office.Interop.Excel.
        DocEvents_BeforeRightClickEventHandler(
        list3_BeforeRightClick);
}

void list3_BeforeRightClick(Microsoft.Office.Interop.Excel.Range 
    Target, ref bool Cancel)
{
    MessageBox.Show("Data binding is " + list3.IsBinding);
    Cancel = true;
}

This version is for an application-level add-in.

ListObject list3;
private void ListObject_BeforeRightClick()
{
    Worksheet vstoWorksheet = 
        Globals.Factory.GetVstoObject(this.Application.ActiveWorkbook.Worksheets[1]);
    list3 = vstoWorksheet.Controls.AddListObject(
        vstoWorksheet.Range["A1", "C4"], "list3");
    list3.BeforeRightClick += new
        Excel.DocEvents_BeforeRightClickEventHandler(
        list3_BeforeRightClick);
}

void list3_BeforeRightClick(Microsoft.Office.Interop.Excel.Range
    Target, ref bool Cancel)
{
    System.Windows.Forms.MessageBox.Show("Data binding is " + list3.IsBinding);
    Cancel = true;
}
Return to top
Show: