表示将要处理 Action 的 BeforeCaptionShow 事件的方法。
命名空间: Microsoft.Office.Tools.Word
程序集: Microsoft.Office.Tools.Word(在 Microsoft.Office.Tools.Word.dll 中)
语法
声明
Public Delegate Sub BeforeCaptionShowEventHandler ( _
sender As Object, _
e As ActionEventArgs _
)
public delegate void BeforeCaptionShowEventHandler(
Object sender,
ActionEventArgs e
)
参数
- sender
类型:System.Object
事件源。
- e
类型:Microsoft.Office.Tools.Word.ActionEventArgs
一个包含事件数据的 ActionEventArgs。
备注
当创建 BeforeCaptionShowEventHandler 委托时,将标识处理事件的方法。 若要使该事件与事件处理程序相关联,请将该委托的一个实例添加到事件中。 除非移除了该委托,否则每当发生该事件时就调用事件处理程序。 有关委托的更多信息,请参见事件和委托。
示例
下面的代码示例创建一个智能标记,此标记能识别两个术语并提供一个操作。 然后该示例为 BeforeCaptionShow 和 Click 事件添加事件处理程序。 若要测试这段代码,请在文档中键入单词“term”和“recognize”,然后尝试智能标记操作。
此示例针对的是文档级自定义项。
Private WithEvents displayAddress As Microsoft.Office.Tools.Word.Action
Private Sub AddSmartTag()
' Create the smart tag for .NET Framework 4 projects.
Dim smartTagDemo As Microsoft.Office.Tools.Word.SmartTag = Globals.Factory.CreateSmartTag(
"www.microsoft.com/Demo#DemoSmartTag",
"Demonstration Smart Tag")
' For .NET Framework 3.5 projects, use the following code to create the smart tag.
' Dim smartTagDemo As New _
' Microsoft.Office.Tools.Word.SmartTag( _
' "www.microsoft.com/Demo#DemoSmartTag", _
' "Demonstration Smart Tag")
' Specify the terms to recognize.
smartTagDemo.Terms.Add("term")
smartTagDemo.Terms.Add("recognize")
' Create the action for .NET Framework 4 projects.
displayAddress = Globals.Factory.CreateAction("To be replaced")
' For .NET Framework 3.5 projects, use the following code to create the action.
' displayAddress = New Microsoft.Office.Tools.Word.Action("To be replaced")
' Add the action to the smart tag.
smartTagDemo.Actions = New Microsoft.Office.Tools.Word.Action() { _
displayAddress}
' Add the smart tag.
Me.VstoSmartTags.Add(smartTagDemo)
End Sub
private Microsoft.Office.Tools.Word.Action displayAddress;
private void AddSmartTag()
{
// Create the smart tag for .NET Framework 4 projects.
Microsoft.Office.Tools.Word.SmartTag smartTagDemo =
Globals.Factory.CreateSmartTag(
"www.microsoft.com/Demo#DemoSmartTag",
"Demonstration Smart Tag");
// For .NET Framework 3.5 projects, use the following code to create the smart tag.
// Microsoft.Office.Tools.Word.SmartTag smartTagDemo =
// new Microsoft.Office.Tools.Word.SmartTag(
// "www.microsoft.com/Demo#DemoSmartTag",
// "Demonstration Smart Tag");
// Specify the terms to recognize.
smartTagDemo.Terms.Add("term");
smartTagDemo.Terms.Add("recognize");
// Create the action for .NET Framework 4 projects.
displayAddress = Globals.Factory.CreateAction("To be replaced");
// For .NET Framework 3.5 projects, use the following code to create the action.
// displayAddress = new Microsoft.Office.Tools.Word.Action("To be replaced");
// Add the action to the smart tag.
smartTagDemo.Actions = new Microsoft.Office.Tools.Word.Action[] {
displayAddress };
// Add the smart tag.
this.VstoSmartTags.Add(smartTagDemo);
displayAddress.BeforeCaptionShow += new
Microsoft.Office.Tools.Word.BeforeCaptionShowEventHandler(
displayAddress_BeforeCaptionShow);
displayAddress.Click += new
Microsoft.Office.Tools.Word.ActionClickEventHandler(
displayAddress_Click);
}