다음을 통해 공유


ControlCollection.GetShapeForControl 메서드

지정된 컨트롤에 대한 내부 Shape을 가져옵니다.

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

구문

‘선언
Function GetShapeForControl ( _
    control As Control _
) As Shape
Shape GetShapeForControl(
    Control control
)

매개 변수

반환 값

형식: Microsoft.Office.Interop.Word.Shape
지정된 컨트롤에 대한 내부 Shape입니다.

설명

컨트롤의 줄 바꿈 스타일이 텍스트 줄 안으로 설정되어 있으면 GetShapeForControl 메서드에서 nullNull 참조(Visual Basic의 경우 Nothing)을 반환합니다.

예제

다음 코드 예제에서는 문서에 Button을 추가한 다음 GetShapeForControl 메서드를 사용하여 컨트롤의 내부 Shape에서 컨트롤의 위치를 가져옵니다.

Private Sub WordGetShape()
    Dim testButton As Microsoft.Office.Tools.Word.Controls.Button = _
        Me.Controls.AddButton(10, 10, 50, 25, "testButton")

    Dim buttonShape As Microsoft.Office.Interop.Word.Shape = _
            Me.Controls.GetShapeForControl(testButton)

    If buttonShape IsNot Nothing Then
        MessageBox.Show("The following properties can be cached in the" & _
            vbCrLf & "document to enable you to recreate the control:" _
            & vbCrLf & vbCrLf & "Height: " & buttonShape.Height _
            & vbCrLf & "Width: " & buttonShape.Width _
            & vbCrLf & "Top: " & buttonShape.Top _
            & vbCrLf & "Left: " & buttonShape.Left)
    End If
End Sub
private void WordGetShape()
{
    Microsoft.Office.Tools.Word.Controls.Button testButton =
        this.Controls.AddButton(10, 10, 50, 25, "testButton");

    Microsoft.Office.Interop.Word.Shape buttonShape =
        this.Controls.GetShapeForControl(testButton);

    if (buttonShape != null)
    {
        MessageBox.Show("The following properties can be cached in the" +
            "\n" + "document to enable you to recreate the control:" +
            "\n\n" + "Height: " + buttonShape.Height.ToString() +
            "\n" + "Width: " + buttonShape.Width.ToString() + "\n" +
            "Top: " + buttonShape.Top.ToString() + "\n" +
            "Left: " + buttonShape.Left.ToString());
    }
}

.NET Framework 보안

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

참고 항목

참조

ControlCollection 인터페이스

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