ListObject.BeforeRightClick Event (2007 System)
Occurs when the ListObject 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 ListObject
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 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.
WithEvents List3 As Microsoft.Office.Tools.Excel.ListObject
Private Sub ListObject_BeforeRightClick()
List3 = Me.Controls.AddListObject( _
Me.Range("A1", "C4"), "List3")
End Sub
Sub List3_BeforeRightClick(ByVal Target As _
Microsoft.Office.Interop.Excel.Range, _
ByRef Cancel As Boolean) Handles List3.BeforeRightClick
MessageBox.Show("Data binding is " & List3.IsBinding)
Cancel = True
End Sub
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.
WithEvents List3 As ListObject
Private Sub ListObject_BeforeRightClick()
Dim vstoWorksheet As Worksheet = CType( _
Me.Application.ActiveWorkbook.Worksheets(1), _
Excel.Worksheet).GetVstoObject()
List3 = vstoWorksheet.Controls.AddListObject( _
vstoWorksheet.Range("A1", "C4"), "List3")
End Sub
Sub List3_BeforeRightClick(ByVal Target As _
Microsoft.Office.Interop.Excel.Range, _
ByRef Cancel As Boolean) Handles List3.BeforeRightClick
System.Windows.Forms.MessageBox.Show("Data binding is " & List3.IsBinding)
Cancel = True
End Sub
ListObject list3;
private void ListObject_BeforeRightClick()
{
Worksheet vstoWorksheet = ((Excel.Worksheet)
this.Application.ActiveWorkbook.Worksheets[1]).GetVstoObject();
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;
}
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.
See Also
Reference
Microsoft.Office.Tools.Excel Namespace
Change History
Date |
History |
Reason |
---|---|---|
July 2008 |
Added a version of the code example for an application-level add-in. |
SP1 feature change. |