Interfaccia SmartTagCollection

Rappresenta una raccolta di smart tag in una soluzione Word o Excel creata tramite gli Strumenti di sviluppo di Microsoft Office per Visual Studio.

Spazio dei nomi:  Microsoft.Office.Tools
Assembly:  Microsoft.Office.Tools.Common (in Microsoft.Office.Tools.Common.dll)

Sintassi

'Dichiarazione
<GuidAttribute("30a90086-8c89-4e19-8299-47765d808408")> _
Public Interface SmartTagCollection _
    Inherits IEnumerable, IDisposable
[GuidAttribute("30a90086-8c89-4e19-8299-47765d808408")]
public interface SmartTagCollection : IEnumerable, 
    IDisposable

Il tipo SmartTagCollection espone i seguenti membri.

Proprietà

  Nome Descrizione
Proprietà pubblica Item Ottiene lo smart tag in corrispondenza dell'indice specificato.

In alto

Metodi

  Nome Descrizione
Metodo pubblico Add Aggiunge uno smart tag alla fine dell'oggetto SmartTagCollection.
Metodo pubblico AddRange Aggiunge una matrice di smart tag alla fine dell'oggetto SmartTagCollection.
Metodo pubblico BeginInit Infrastruttura.
Metodo pubblico Contains Consente di stabilire se l'oggetto SmartTagCollection contiene uno smart tag specifico.
Metodo pubblico CopyTo Copia gli smart tag presenti nell'oggetto SmartTagCollection in una matrice unidimensionale di smart tag, a partire dall'indice specificato.
Metodo pubblico Dispose Esegue attività definite dall'applicazione, ad esempio libera, rilascia o reimposta risorse non gestite. (Ereditato da IDisposable)
Metodo pubblico EndInit Infrastruttura.
Metodo pubblico GetEnumerator Viene restituito un enumeratore che scorre un insieme. (Ereditato da IEnumerable)
Metodo pubblico IndexOf Determina l'indice di uno smart tag specificato nell'oggetto SmartTagCollection.
Metodo pubblico Insert Inserisce uno smart tag nell'oggetto SmartTagCollection in corrispondenza dell'indice specificato.
Metodo pubblico Remove Rimuove uno smart tag dall'oggetto SmartTagCollection.

In alto

Note

Quando si crea uno smart tag, aggiungere un oggetto SmartTagBase alle proprietà Workbook.VstoSmartTags o Document.VstoSmartTags. Il tipo di tali proprietà è SmartTagCollection.

Per ulteriori informazioni sugli smart tag nelle soluzioni Office, vedere Cenni preliminari sugli smart tag.

Nota

Questa interfaccia è implementata da Visual Studio Tools per Office Runtime. Non deve essere implementata nel codice. Per ulteriori informazioni, vedere Cenni preliminari su Visual Studio Tools per Office Runtime.

Utilizzo

Questo tipo deve essere utilizzato solo nei progetti per Excel 2007 e Word 2007. In Excel 2010 e Word 2010 gli smart tag sono stati deprecati. Per ulteriori informazioni, vedere Cenni preliminari sugli smart tag.

Nella presente documentazione viene descritta la versione di questo tipo utilizzata nei progetti di Office destinati a .NET Framework 4. Nei progetti destinati a .NET Framework 3.5, questo tipo potrebbe avere membri diversi e gli esempi di codice forniti per il tipo potrebbero non funzionare. Per la documentazione relativa a questo tipo nei progetti destinati a .NET Framework 3.5, vedere la sezione di riferimento seguente nella documentazione di Visual Studio 2008: https://go.microsoft.com/fwlink/?LinkId=160658.

Esempi

Nell'esempio di codice riportato di seguito viene utilizzato il metodo Add per aggiungere un oggetto Microsoft.Office.Tools.Excel.SmartTag all'insieme di smart tag esposto dalla proprietà Workbook.VstoSmartTags. Questo esempio di codice fa parte di un esempio più esaustivo fornito per Microsoft.Office.Tools.Excel.Action.

Questo esempio è valido per una personalizzazione a livello di documento.

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

Private Sub AddSmartTag()

    ' Create the smart tag for .NET Framework 4 projects.
    Dim smartTagDemo As Microsoft.Office.Tools.Excel.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.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 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.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()
{
    // Create the smart tag for .NET Framework 4 projects.
    Microsoft.Office.Tools.Excel.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.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 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.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);
}

Vedere anche

Riferimenti

Spazio dei nomi Microsoft.Office.Tools

Altre risorse

Cenni preliminari sugli smart tag