ListObject.BeforeRightClick 事件 (2007 系統)
更新: 2008 年 7 月
會在 ListObject 控制項上按一下滑鼠右鍵時發生 (在預設按滑鼠右鍵動作執行之前)。
命名空間: Microsoft.Office.Tools.Excel
組件: Microsoft.Office.Tools.Excel.v9.0 (在 Microsoft.Office.Tools.Excel.v9.0.dll 中)
語法
Public Event BeforeRightClick As DocEvents_BeforeRightClickEventHandler
Dim instance As ListObject
Dim handler As DocEvents_BeforeRightClickEventHandler
AddHandler instance.BeforeRightClick, handler
public event DocEvents_BeforeRightClickEventHandler BeforeRightClick
範例
下列程式碼範例會建立 ListObject 和 BeforeRightClick 事件處理常式。以滑鼠右鍵按一下清單物件時,會顯示訊息,指出清單物件是否繫結至資料。
這是示範文件層級自訂的版本。
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;
}
這是示範應用程式層級增益集的版本。
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;
}
使用權限
- 完全信任立即呼叫者。這個成員無法供部分信任的程式碼使用。如需詳細資訊,請參閱從部分受信任程式碼使用程式庫。
請參閱
參考
Microsoft.Office.Tools.Excel 命名空間
變更記錄
日期 |
記錄 |
原因 |
---|---|---|
2008 年 7 月 |
加入應用程式層級增益集的程式碼範例版本。 |
SP1 功能變更。 |