SmartTagCollection 类 (2007 system)

更新:2007 年 11 月

表示 Visual Studio Tools for Office 解决方案中的智能标记的集合。

命名空间:  Microsoft.Office.Tools
程序集:  Microsoft.Office.Tools.Common.v9.0(在 Microsoft.Office.Tools.Common.v9.0.dll 中)

语法

声明
<PermissionSetAttribute(SecurityAction.Demand, Name := "FullTrust")> _
Public Class SmartTagCollection _
    Inherits CollectionBase _
    Implements ISupportInitialize, IDisposable
用法
Dim instance As SmartTagCollection
[PermissionSetAttribute(SecurityAction.Demand, Name = "FullTrust")]
public class SmartTagCollection : CollectionBase, 
    ISupportInitialize, IDisposable

备注

在 Visual Studio Tools for Office 解决方案中创建智能标记时,您会将一个 SmartTagBase 对象添加到 Workbook.VstoSmartTagsDocument.VstoSmartTags 属性。这些属性具有类型 SmartTagCollection。

有关 Visual Studio Tools for Office 解决方案中的智能标记的更多信息,请参见智能标记概述

示例

下面的代码使用 Add 方法将 Microsoft.Office.Tools.Excel.SmartTag 添加到 Workbook.VstoSmartTags 属性公开的智能标记的集合中。此代码示例摘自为 Microsoft.Office.Tools.Excel.Action 类提供的一个更大示例。

此示例针对的是文档级自定义项。

WithEvents displayAddress As Microsoft.Office.Tools.Excel.Action

Private Sub AddSmartTag()
    Dim smartTagDemo As New  _
        Microsoft.Office.Tools.Excel.SmartTag( _
        "www.microsoft.com/Demo#DemoSmartTag", _
        "Demonstration Smart Tag")

    ' Specify a term and an expression to recognize.
    smartTagDemo.Terms.Add("sale")
    smartTagDemo.Expressions.Add( _
        New System.Text.RegularExpressions.Regex( _
        "[I|i]ssue\s\d{5,6}"))

    ' Create the action.
    displayAddress = New Microsoft.Office.Tools.Excel.Action( _
        "To be replaced")

    ' Add the action to the smart tag.
    smartTagDemo.Actions = New Microsoft.Office.Tools.Excel.Action() { _
            displayAddress}

    ' Add the smart tag.
    Me.VstoSmartTags.Add(smartTagDemo)
End Sub
private Microsoft.Office.Tools.Excel.Action displayAddress;

private void AddSmartTag()
{
    Microsoft.Office.Tools.Excel.SmartTag smartTagDemo =
        new Microsoft.Office.Tools.Excel.SmartTag(
        "www.microsoft.com/Demo#DemoSmartTag",
        "Demonstration Smart Tag");

    // Specify a term and an expression to recognize.
    smartTagDemo.Terms.Add("sale");
    smartTagDemo.Expressions.Add(
        new System.Text.RegularExpressions.Regex(
        @"[I|i]ssue\s\d{5,6}"));

    // Create the action.
    displayAddress = new Microsoft.Office.Tools.Excel.Action(
        "To be replaced");

    // Add the action to the smart tag.
    smartTagDemo.Actions = new Microsoft.Office.Tools.Excel.Action[] { 
        displayAddress };

    // Add the smart tag.
    this.VstoSmartTags.Add(smartTagDemo);

    displayAddress.BeforeCaptionShow += new 
        Microsoft.Office.Tools.Excel.BeforeCaptionShowEventHandler(
        DisplayAddress_BeforeCaptionShow);

    displayAddress.Click += new 
        Microsoft.Office.Tools.Excel.ActionClickEventHandler(
        DisplayAddress_Click);
}

继承层次结构

System.Object
  System.Collections.CollectionBase
    Microsoft.Office.Tools.SmartTagCollection

线程安全

此类型的任何公共 static(在 Visual Basic 中为 Shared) 成员都是线程安全的。但不保证所有实例成员都是线程安全的。

另请参见

参考

SmartTagCollection 成员

Microsoft.Office.Tools 命名空间

其他资源

智能标记概述