Aracılığıyla paylaş


DocumentBase.SelectContentControlsByTag Yöntem

İçerik denetimlerini belgede belirtilen etikete sahip verir.

Ad alanı:  Microsoft.Office.Tools.Word
Derleme:  Microsoft.Office.Tools.Word.v4.0.Utilities (Microsoft.Office.Tools.Word.v4.0.Utilities.dll içinde)

Sözdizimi

'Bildirim
Public Function SelectContentControlsByTag ( _
    tag As String _
) As ContentControls
public ContentControls SelectContentControlsByTag(
    string tag
)

Parametreler

  • tag
    Tür: System.String
    Geri dönmek için içerik denetimlerini etiketi.

Dönüş Değeri

Tür: Microsoft.Office.Interop.Word.ContentControls
A ContentControls belirtilen etiket içerik denetimleri içeren koleksiyonu.

Örnekler

Aşağıdaki kod örneğinde, üç paragraf belgeye ekler ve sonra yeni her paragraf için bir denetim ekler: bir RichTextContentControl, ComboBoxContentControlve bir DropDownListContentControl.Örnek, her denetim etiket ve başlık özelliklerini ayarlar.Ardından, kodu çağırır SelectContentControlsByTag yerel içerik denetimleri topluluğu etiket değerini almak için yöntemini müşteri eşittir ve döndürülen koleksiyon her denetimin başlığı bir ileti kutusunda görüntüler.Bu örneği kullanmak için çalıştırın ThisDocument bir belge düzeyi projesinde sınıf.

Private Sub ContentControlsTag()
    Dim par1 As Word.Paragraph = Me.Paragraphs.Add()
    Dim richTextControl As  _
        Microsoft.Office.Tools.Word.RichTextContentControl = _
        Me.Controls.AddRichTextContentControl(par1.Range, "richTextControl")
    richTextControl.Tag = "Customer"
    richTextControl.Title = "Customer Name"

    Dim par2 As Word.Paragraph = Me.Paragraphs.Add()
    Dim comboBoxControl As  _
        Microsoft.Office.Tools.Word.ComboBoxContentControl = _
        Me.Controls.AddComboBoxContentControl(par2.Range, "comboBoxControl")
    comboBoxControl.Tag = "Customer"
    comboBoxControl.Title = "Customer Title"

    Dim par3 As Word.Paragraph = Me.Paragraphs.Add()
    Dim dropDownListControl As  _
        Microsoft.Office.Tools.Word.DropDownListContentControl = _
        Me.Controls.AddDropDownListContentControl(par3.Range, _
            "dropDownListControl")
    dropDownListControl.Tag = "Products"
    dropDownListControl.Title = "List of Products"

    Dim relatedControls As Word.ContentControls = _
        Me.SelectContentControlsByTag("Customer")
    MessageBox.Show("Displaying all controls with a Tag value of" + _
                    " 'Customer'. Click OK to continue.")
    For Each ctrl As Word.ContentControl In relatedControls
        MessageBox.Show("Control title: " + ctrl.Title)
    Next
End Sub
private void ContentControlsTag()
{
    Word.Paragraph par1 = this.Paragraphs.Add(ref missing);
    Microsoft.Office.Tools.Word.RichTextContentControl richTextControl =
        this.Controls.AddRichTextContentControl(par1.Range, 
        "richTextControl");
    richTextControl.Tag = "Customer";
    richTextControl.Title = "Customer Name";

    Word.Paragraph par2 = this.Paragraphs.Add(ref missing);
    Microsoft.Office.Tools.Word.ComboBoxContentControl comboBoxControl =
        this.Controls.AddComboBoxContentControl(par2.Range, 
        "comboBoxControl");
    comboBoxControl.Tag = "Customer";
    comboBoxControl.Title = "Customer Title";

    Word.Paragraph par3 = this.Paragraphs.Add(ref missing);
    Microsoft.Office.Tools.Word.DropDownListContentControl 
        dropDownListControl = this.Controls.AddDropDownListContentControl(
        par3.Range, "dropDownListControl");
    dropDownListControl.Tag = "Products";
    dropDownListControl.Title = "List of Products";

    Word.ContentControls relatedControls = 
        this.SelectContentControlsByTag("Customer");
    MessageBox.Show("Displaying all controls with a Tag value of" + 
        " 'Customer'. Click OK to continue.");
    foreach (Word.ContentControl ctrl in relatedControls)
    {
        MessageBox.Show("Control title: " + ctrl.Title);
    }
}

.NET Framework Güvenliği

Ayrıca bkz.

Başvuru

DocumentBase Sınıf

Microsoft.Office.Tools.Word Ad Alanı