Share via


DocumentBase.SelectContentControlsByTitle 메서드

문서에서 지정된 제목이 있는 모든 콘텐츠 컨트롤을 반환합니다.

네임스페이스:  Microsoft.Office.Tools.Word
어셈블리:  Microsoft.Office.Tools.Word.v4.0.Utilities(Microsoft.Office.Tools.Word.v4.0.Utilities.dll)

구문

‘선언
Public Function SelectContentControlsByTitle ( _
    title As String _
) As ContentControls
public ContentControls SelectContentControlsByTitle(
    string title
)

매개 변수

  • title
    형식: System.String
    반환할 콘텐츠 컨트롤의 제목입니다.

반환 값

형식: Microsoft.Office.Interop.Word.ContentControls
지정된 제목이 있는 콘텐츠 컨트롤이 들어 있는 ContentControls 컬렉션입니다.

예제

다음 코드 예제에서는 문서에 두 개의 단락을 추가한 다음 이 새 단락에 각각 RichTextContentControlComboBoxContentControl 컨트롤을 추가합니다. 또한 이 예제에서는 각 컨트롤의 Tag 및 Title 속성을 설정합니다. 그런 다음 SelectContentControlsByTitle 메서드를 호출하여 제목이 Customer인 네이티브 콘텐츠 컨트롤의 컬렉션을 가져오고 반환된 컬렉션(이 예제의 경우에는 ComboBoxContentControl만 포함됨)에 있는 각 컨트롤의 자리 표시자 텍스트를 수정합니다. 이 예제를 사용하려면 문서 수준 프로젝트 ThisDocument 클래스에서 실행하십시오.

Private Sub ContentControlsTitle()
    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 myControls As Word.ContentControls = _
        Me.SelectContentControlsByTitle("Customer Title")
    For Each ctrl As Word.ContentControl In myControls
        ctrl.SetPlaceholderText(Text:="Select a title.")
    Next
End Sub
private void ContentControlsTitle()
{                        
    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.ContentControls myControls = 
        this.SelectContentControlsByTitle("Customer Title");
    foreach (Word.ContentControl ctrl in myControls)
    {                                
        ctrl.SetPlaceholderText(null, null, "Select a title.");                
    }
}

.NET Framework 보안

  • 직접 실행 호출자의 경우 완전히 신뢰합니다. 이 멤버는 부분적으로 신뢰할 수 있는 코드에서 사용할 수 없습니다. 자세한 내용은 부분 신뢰 코드에서 라이브러리 사용을 참조하십시오.

참고 항목

참조

DocumentBase 클래스

Microsoft.Office.Tools.Word 네임스페이스