Share via


ControlCollection.AddBuildingBlockGalleryContentControl 메서드

정의

오버로드

AddBuildingBlockGalleryContentControl(String)

문서의 현재 선택 영역에서 새 BuildingBlockGalleryContentControl을 추가합니다.

AddBuildingBlockGalleryContentControl(ContentControl, String)

컬렉션에 새 BuildingBlockGalleryContentControl를 추가합니다. 새 컨트롤은 문서에 이미 있는 네이티브 콘텐츠 컨트롤을 기반으로 합니다.

AddBuildingBlockGalleryContentControl(Range, String)

문서의 지정된 범위에 새 BuildingBlockGalleryContentControl을 추가합니다.

AddBuildingBlockGalleryContentControl(String)

문서의 현재 선택 영역에서 새 BuildingBlockGalleryContentControl을 추가합니다.

public:
 Microsoft::Office::Tools::Word::BuildingBlockGalleryContentControl ^ AddBuildingBlockGalleryContentControl(System::String ^ name);
public Microsoft.Office.Tools.Word.BuildingBlockGalleryContentControl AddBuildingBlockGalleryContentControl (string name);
abstract member AddBuildingBlockGalleryContentControl : string -> Microsoft.Office.Tools.Word.BuildingBlockGalleryContentControl
Public Function AddBuildingBlockGalleryContentControl (name As String) As BuildingBlockGalleryContentControl

매개 변수

name
String

새 컨트롤의 이름입니다.

반환

문서에 추가된 BuildingBlockGalleryContentControl입니다.

예외

namenull이거나 길이가 0입니다.

ControlCollection에 동일한 이름의 컨트롤이 이미 있습니다.

예제

다음 코드 예제에서는 문서의 시작 부분에 새 BuildingBlockGalleryContentControl 를 추가합니다. 는 BuildingBlockGalleryContentControl Microsoft Office Word 제공하는 수식 구성 요소를 표시합니다.

이 버전은 문서 수준 사용자 지정을 위한 것입니다. 이 코드를 사용하려면 프로젝트의 클래스에 ThisDocument 붙여넣고 메서드에서 메서드를 AddBuildingBlockControlAtSelectionThisDocument_Startup 호출합니다.

private Microsoft.Office.Tools.Word.BuildingBlockGalleryContentControl buildingBlockControl1;

private void AddBuildingBlockControlAtSelection()
{
    this.Paragraphs[1].Range.InsertParagraphBefore();
    this.Paragraphs[1].Range.Select();

    buildingBlockControl1 = this.Controls.AddBuildingBlockGalleryContentControl(
        "buildingBlockControl1");
    buildingBlockControl1.PlaceholderText = "Choose an equation";
    buildingBlockControl1.BuildingBlockCategory = "Built-In";
    buildingBlockControl1.BuildingBlockType = Word.WdBuildingBlockTypes.wdTypeEquations;
}
Dim buildingBlockGalleryControl1 As Microsoft.Office.Tools.Word.BuildingBlockGalleryContentControl

Private Sub AddBuildingBlockGalleryControlAtSelection()
    Me.Paragraphs(1).Range.InsertParagraphBefore()
    Me.Paragraphs(1).Range.Select()
    buildingBlockGalleryControl1 = Me.Controls.AddBuildingBlockGalleryContentControl( _
        "buildingBlockGalleryControl1")
    With buildingBlockGalleryControl1
        .PlaceholderText = "Choose an equation"
        .BuildingBlockCategory = "Built-In"
        .BuildingBlockType = Word.WdBuildingBlockTypes.wdTypeEquations
    End With
End Sub

이 버전은 .NET Framework 4 또는 .NET Framework 4.5를 대상으로 하는 애플리케이션 수준 추가 기능용입니다. 이 코드를 사용하려면 프로젝트의 클래스에 ThisAddIn 붙여넣고 메서드에서 메서드를 AddBuildingBlockControlAtSelectionThisAddIn_Startup 호출합니다.

private Microsoft.Office.Tools.Word.BuildingBlockGalleryContentControl buildingBlockControl1;

private void AddBuildingBlockControlAtSelection()
{
    if (this.Application.ActiveDocument == null)
        return;

    Document vstoDoc = Globals.Factory.GetVstoObject(this.Application.ActiveDocument);
    vstoDoc.Paragraphs[1].Range.InsertParagraphBefore();
    vstoDoc.Paragraphs[1].Range.Select();

    buildingBlockControl1 = vstoDoc.Controls.AddBuildingBlockGalleryContentControl(
        "buildingBlockControl1");
    buildingBlockControl1.PlaceholderText = "Choose an equation";
    buildingBlockControl1.BuildingBlockCategory = "Built-In";
    buildingBlockControl1.BuildingBlockType = Word.WdBuildingBlockTypes.wdTypeEquations;
}
Dim buildingBlockGalleryControl1 As BuildingBlockGalleryContentControl

Private Sub AddBuildingBlockGalleryControlAtSelection()
    If Me.Application.ActiveDocument Is Nothing Then
        Return
    End If

    Dim vstoDoc As Document = Globals.Factory.GetVstoObject(Me.Application.ActiveDocument)
    vstoDoc.Paragraphs(1).Range.InsertParagraphBefore()
    vstoDoc.Paragraphs(1).Range.Select()
    buildingBlockGalleryControl1 = vstoDoc.Controls.AddBuildingBlockGalleryContentControl( _
        "buildingBlockGalleryControl1")
    With buildingBlockGalleryControl1
        .PlaceholderText = "Choose an equation"
        .BuildingBlockCategory = "Built-In"
        .BuildingBlockType = Word.WdBuildingBlockTypes.wdTypeEquations
    End With
End Sub

설명

이 메서드를 사용하여 런타임에 문서의 현재 선택 영역에 새 BuildingBlockGalleryContentControl 를 추가합니다. 자세한 내용은 Adding Controls to Office Documents at Run Time을 참조하세요.

적용 대상

AddBuildingBlockGalleryContentControl(ContentControl, String)

컬렉션에 새 BuildingBlockGalleryContentControl를 추가합니다. 새 컨트롤은 문서에 이미 있는 네이티브 콘텐츠 컨트롤을 기반으로 합니다.

public:
 Microsoft::Office::Tools::Word::BuildingBlockGalleryContentControl ^ AddBuildingBlockGalleryContentControl(Microsoft::Office::Interop::Word::ContentControl ^ contentControl, System::String ^ name);
public Microsoft.Office.Tools.Word.BuildingBlockGalleryContentControl AddBuildingBlockGalleryContentControl (Microsoft.Office.Interop.Word.ContentControl contentControl, string name);
abstract member AddBuildingBlockGalleryContentControl : Microsoft.Office.Interop.Word.ContentControl * string -> Microsoft.Office.Tools.Word.BuildingBlockGalleryContentControl
Public Function AddBuildingBlockGalleryContentControl (contentControl As ContentControl, name As String) As BuildingBlockGalleryContentControl

매개 변수

contentControl
ContentControl

새 컨트롤에 대한 기준인 ContentControl입니다.

name
String

새 컨트롤의 이름입니다.

반환

문서에 추가된 BuildingBlockGalleryContentControl입니다.

예외

contentControlnull.-또는- namenull 거나 길이가 0입니다.

ControlCollection에 동일한 이름의 컨트롤이 이미 있습니다.

contentControl은 문서 블록 갤러리가 아닙니다(즉, TypecontentControl 속성에 Microsoft.Office.Interop.Word 값이 없습니다. WdContentControlType.wdContentControlBuildingBlockGallery).

예제

다음 코드 예제에서는 문서에 이미 있는 모든 네이티브 문서 블록 갤러리에 대해 새 BuildingBlockGalleryContentControl 를 만듭니다.

이 버전은 문서 수준 사용자 지정을 위한 것입니다. 이 코드를 사용하려면 프로젝트의 클래스에 ThisDocument 붙여넣고 메서드에서 메서드를 CreateBuildingBlockControlsFromNativeControlsThisDocument_Startup 호출합니다.

private System.Collections.Generic.List
   <Microsoft.Office.Tools.Word.BuildingBlockGalleryContentControl> buildingBlockControls;

private void CreateBuildingBlockControlsFromNativeControls()
{
    if (this.ContentControls.Count <= 0)
        return;

    buildingBlockControls = new System.Collections.Generic.List
        <Microsoft.Office.Tools.Word.BuildingBlockGalleryContentControl>();
    int count = 0;

    foreach (Word.ContentControl nativeControl in this.ContentControls)
    {
        if (nativeControl.Type == Word.WdContentControlType.wdContentControlBuildingBlockGallery)
        {
            count++;
            Microsoft.Office.Tools.Word.BuildingBlockGalleryContentControl tempControl =
                this.Controls.AddBuildingBlockGalleryContentControl(nativeControl,
                "VSTOBuildingBlockContentControl" + count.ToString());
            buildingBlockControls.Add(tempControl);
        }
    }
}
Private buildingBlockControls As New System.Collections.Generic.List _
        (Of Microsoft.Office.Tools.Word.BuildingBlockGalleryContentControl)

Private Sub CreateBuildingBlockGalleryControlsFromNativeControls()
    If Me.ContentControls.Count <= 0 Then
        Return
    End If

    Dim count As Integer = 0
    For Each nativeControl As Word.ContentControl In Me.ContentControls
        If nativeControl.Type = Word.WdContentControlType.wdContentControlBuildingBlockGallery Then
            count += 1
            Dim tempControl As Microsoft.Office.Tools.Word.BuildingBlockGalleryContentControl = _
                Me.Controls.AddBuildingBlockGalleryContentControl(nativeControl, _
                "VSTOBuildingBlockGalleryContentControl" + count.ToString())
            buildingBlockControls.Add(tempControl)
        End If
    Next nativeControl
End Sub

이 버전은 .NET Framework 4 또는 .NET Framework 4.5를 대상으로 하는 애플리케이션 수준 추가 기능용입니다. 이 코드를 사용하려면 추가 기능 프로젝트의 클래스에 ThisAddIn 붙여넣고 메서드에서 메서드를 CreateBuildingBlockControlsFromNativeControlsThisAddIn_Startup 호출합니다.

private System.Collections.Generic.List
   <Microsoft.Office.Tools.Word.BuildingBlockGalleryContentControl> buildingBlockControls;

private void CreateBuildingBlockControlsFromNativeControls()
{
    if (this.Application.ActiveDocument == null)
        return;

    Document vstoDoc = Globals.Factory.GetVstoObject(this.Application.ActiveDocument);
    if (vstoDoc.ContentControls.Count <= 0)
    {
        System.Windows.Forms.MessageBox.Show("No content controls found in document.");                    
        return;
    }

    buildingBlockControls = new System.Collections.Generic.List
        <Microsoft.Office.Tools.Word.BuildingBlockGalleryContentControl>();
    int count = 0;

    foreach (Word.ContentControl nativeControl in vstoDoc.ContentControls)
    {
        if (nativeControl.Type == Word.WdContentControlType.wdContentControlBuildingBlockGallery)
        {
            count++;
            Microsoft.Office.Tools.Word.BuildingBlockGalleryContentControl tempControl =
                vstoDoc.Controls.AddBuildingBlockGalleryContentControl(nativeControl,
                "VSTOBuildingBlockContentControl" + count.ToString());
            buildingBlockControls.Add(tempControl);
        }
    }
}
Private buildingBlockControls As New System.Collections.Generic.List _
        (Of BuildingBlockGalleryContentControl)

Private Sub CreateBuildingBlockGalleryControlsFromNativeControls()
    If Me.Application.ActiveDocument Is Nothing Then
        Return
    End If

    Dim vstoDoc As Document = Globals.Factory.GetVstoObject(Me.Application.ActiveDocument)
    If vstoDoc.ContentControls.Count <= 0 Then
        Return
    End If

    Dim count As Integer = 0
    For Each nativeControl As Word.ContentControl In vstoDoc.ContentControls
        If nativeControl.Type = Word.WdContentControlType.wdContentControlBuildingBlockGallery Then
            count += 1
            Dim tempControl As Microsoft.Office.Tools.Word.BuildingBlockGalleryContentControl = _
                vstoDoc.Controls.AddBuildingBlockGalleryContentControl(nativeControl, _
                "VSTOBuildingBlockGalleryContentControl" + count.ToString())
            buildingBlockControls.Add(tempControl)
        End If
    Next nativeControl
End Sub

다음 코드 예제에서는 사용자가 문서에 추가하는 모든 네이티브 문서 블록 갤러리에 대해 새 BuildingBlockGalleryContentControl 를 만듭니다.

이 버전은 문서 수준 사용자 지정을 위한 것입니다. 이 코드를 사용하려면 프로젝트의 클래스에 ThisDocument 붙여넣습니다. C#의 경우 이벤트 처리기를 ContentControlAfterAdd 클래스의 ThisDocument 이벤트에 연결 ThisDocument_BuildingBlockContentControlAfterAdd 해야 합니다.

void ThisDocument_BuildingBlockContentControlAfterAdd(Word.ContentControl NewContentControl, bool InUndoRedo)
{
    if (NewContentControl.Type == Word.WdContentControlType.wdContentControlBuildingBlockGallery)
    {
        this.Controls.AddBuildingBlockGalleryContentControl(NewContentControl,
            "BuildingBlockControl" + NewContentControl.ID);
    }
}
Private Sub ThisDocument_BuildingBlockContentControlAfterAdd(ByVal NewContentControl As Word.ContentControl, _
    ByVal InUndoRedo As Boolean) Handles Me.ContentControlAfterAdd

    If NewContentControl.Type = Word.WdContentControlType.wdContentControlBuildingBlockGallery Then
        Me.Controls.AddBuildingBlockGalleryContentControl(NewContentControl, _
            "BuildingBlockControl" + NewContentControl.ID)
    End If
End Sub

이 버전은 .NET Framework 4 또는 .NET Framework 4.5를 대상으로 하는 애플리케이션 수준 추가 기능용입니다. 이 코드를 사용하려면 프로젝트의 클래스에 ThisAddIn 붙여넣습니다. 또한 이벤트 처리기를 ContentControlAfterAdd 현재 문서의 이벤트에 연결 ActiveDocument_BuildingBlockContentControlAfterAdd 해야 합니다.

void ActiveDocument_BuildingBlockContentControlAfterAdd(
    Word.ContentControl NewContentControl, bool InUndoRedo)
{
    Document vstoDoc = Globals.Factory.GetVstoObject(this.Application.ActiveDocument);
    if (NewContentControl.Type == Word.WdContentControlType.wdContentControlBuildingBlockGallery)
    {
        vstoDoc.Controls.AddBuildingBlockGalleryContentControl(NewContentControl,
            "BuildingBlockControl" + NewContentControl.ID);
    }
}
Private Sub ActiveDocument_BuildingBlockContentControlAfterAdd( _
    ByVal NewContentControl As Word.ContentControl, _
    ByVal InUndoRedo As Boolean)

    Dim vstoDoc As Document = Globals.Factory.GetVstoObject(Me.Application.ActiveDocument)
    If NewContentControl.Type = Word.WdContentControlType. _
        wdContentControlBuildingBlockGallery Then
        vstoDoc.Controls.AddBuildingBlockGalleryContentControl(NewContentControl, _
            "BuildingBlockControl" + NewContentControl.ID)
    End If
End Sub

설명

이 메서드를 사용하여 문서의 네이티브 콘텐츠 컨트롤을 기반으로 하는 새 BuildingBlockGalleryContentControl 를 추가합니다. 런타임에 를 BuildingBlockGalleryContentControl 만들고 다음에 문서를 열 때 동일한 컨트롤을 다시 만들려고 할 때 유용합니다. 자세한 내용은 Adding Controls to Office Documents at Run Time을 참조하세요.

적용 대상

AddBuildingBlockGalleryContentControl(Range, String)

문서의 지정된 범위에 새 BuildingBlockGalleryContentControl을 추가합니다.

public:
 Microsoft::Office::Tools::Word::BuildingBlockGalleryContentControl ^ AddBuildingBlockGalleryContentControl(Microsoft::Office::Interop::Word::Range ^ range, System::String ^ name);
public Microsoft.Office.Tools.Word.BuildingBlockGalleryContentControl AddBuildingBlockGalleryContentControl (Microsoft.Office.Interop.Word.Range range, string name);
abstract member AddBuildingBlockGalleryContentControl : Microsoft.Office.Interop.Word.Range * string -> Microsoft.Office.Tools.Word.BuildingBlockGalleryContentControl
Public Function AddBuildingBlockGalleryContentControl (range As Range, name As String) As BuildingBlockGalleryContentControl

매개 변수

range
Range

새 컨트롤의 범위를 제공하는 Range입니다.

name
String

새 컨트롤의 이름입니다.

반환

문서에 추가된 BuildingBlockGalleryContentControl입니다.

예외

namenull이거나 길이가 0입니다.

ControlCollection에 동일한 이름의 컨트롤이 이미 있습니다.

예제

다음 코드 예제에서는 문서의 시작 부분에 새 BuildingBlockGalleryContentControl 를 추가합니다. 는 BuildingBlockGalleryContentControl Microsoft Office Word 제공하는 수식 구성 요소를 표시합니다.

이 버전은 문서 수준 사용자 지정을 위한 것입니다. 이 코드를 사용하려면 프로젝트의 클래스에 ThisDocument 붙여넣고 메서드에서 메서드를 AddBuildingBlockControlAtRangeThisDocument_Startup 호출합니다.

private Microsoft.Office.Tools.Word.BuildingBlockGalleryContentControl buildingBlockControl2;

private void AddBuildingBlockControlAtRange()
{
    this.Paragraphs[1].Range.InsertParagraphBefore();

    buildingBlockControl2 = this.Controls.AddBuildingBlockGalleryContentControl(
       this.Paragraphs[1].Range, "buildingBlockControl2");
    buildingBlockControl2.PlaceholderText = "Choose an equation";
    buildingBlockControl2.BuildingBlockCategory = "Built-In";
    buildingBlockControl2.BuildingBlockType = Word.WdBuildingBlockTypes.wdTypeEquations;
}
Dim buildingBlockGalleryControl2 As Microsoft.Office.Tools.Word.BuildingBlockGalleryContentControl

Private Sub AddBuildingBlockGalleryControlAtRange()
    Me.Paragraphs(1).Range.InsertParagraphBefore()
    buildingBlockGalleryControl2 = Me.Controls.AddBuildingBlockGalleryContentControl( _
        Me.Paragraphs(1).Range, "buildingBlockGalleryControl2")
    With buildingBlockGalleryControl2
        .PlaceholderText = "Choose an equation"
        .BuildingBlockCategory = "Built-In"
        .BuildingBlockType = Word.WdBuildingBlockTypes.wdTypeEquations
    End With
End Sub

이 버전은 .NET Framework 4 또는 .NET Framework 4.5를 대상으로 하는 애플리케이션 수준 추가 기능용입니다. 이 코드를 사용하려면 프로젝트의 클래스에 ThisAddIn 붙여넣고 메서드에서 메서드를 AddBuildingBlockControlAtRangeThisAddIn_Startup 호출합니다.

private Microsoft.Office.Tools.Word.BuildingBlockGalleryContentControl buildingBlockControl2;

private void AddBuildingBlockControlAtRange()
{
    if (this.Application.ActiveDocument == null)
        return;

    Document vstoDoc = Globals.Factory.GetVstoObject(this.Application.ActiveDocument);
    vstoDoc.Paragraphs[1].Range.InsertParagraphBefore();

    buildingBlockControl2 = vstoDoc.Controls.AddBuildingBlockGalleryContentControl(
       vstoDoc.Paragraphs[1].Range, "buildingBlockControl2");
    buildingBlockControl2.PlaceholderText = "Choose an equation";
    buildingBlockControl2.BuildingBlockCategory = "Built-In";
    buildingBlockControl2.BuildingBlockType = Word.WdBuildingBlockTypes.wdTypeEquations;
}
Dim buildingBlockGalleryControl2 As BuildingBlockGalleryContentControl

Private Sub AddBuildingBlockGalleryControlAtRange()
    If Me.Application.ActiveDocument Is Nothing Then
        Return
    End If

    Dim vstoDoc As Document = Globals.Factory.GetVstoObject(Me.Application.ActiveDocument)
    vstoDoc.Paragraphs(1).Range.InsertParagraphBefore()
    buildingBlockGalleryControl2 = vstoDoc.Controls.AddBuildingBlockGalleryContentControl( _
        vstoDoc.Paragraphs(1).Range, "buildingBlockGalleryControl2")
    With buildingBlockGalleryControl2
        .PlaceholderText = "Choose an equation"
        .BuildingBlockCategory = "Built-In"
        .BuildingBlockType = Word.WdBuildingBlockTypes.wdTypeEquations
    End With
End Sub

설명

이 메서드를 사용하여 런타임에 문서의 지정된 범위에서 새 BuildingBlockGalleryContentControl 를 추가합니다. 자세한 내용은 Adding Controls to Office Documents at Run Time을 참조하세요.

적용 대상