다음을 통해 공유


Button.Delete 메서드

동적으로 만들어진 Button을 워크시트에서 삭제하고 ControlCollection에서 제거합니다.

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

구문

‘선언
Public Function Delete As Object
public Object Delete()

반환 값

형식: System.Object

설명

이 메서드는 런타임에 프로그래밍 방식으로 만들어진 Button에서만 사용해야 합니다.디자인 타임에 워크시트에 추가된 Button에서 이 메서드를 호출하면 예외가 throw됩니다.

예제

다음 코드 예제에서는 사용자가 클릭하면 자신을 삭제하는 Button 컨트롤을 보여 줍니다.단추의 Click 이벤트 처리기는 Delete 메서드를 호출하여 단추를 삭제합니다.

이 예제는 문서 수준 사용자 지정을 위한 것입니다.

Private Sub DeleteControl()
    Dim DeleteButton As Microsoft.Office.Tools.Excel.Controls.Button = _
        Me.Controls.AddButton(25, 75, 80, 30, "DeleteButton")
    DeleteButton.Text = "Click to delete"
    AddHandler DeleteButton.Click, AddressOf DeleteButton_Click
End Sub

' Delete the clicked button.
Private Sub DeleteButton_Click(ByVal sender As Object, ByVal e As EventArgs)
    Dim ClickedButton As Microsoft.Office.Tools.Excel.Controls.Button = _
        CType(sender, Microsoft.Office.Tools.Excel.Controls.Button)

    ClickedButton.Delete()
End Sub
        private void DeleteControl()
        {
            Microsoft.Office.Tools.Excel.Controls.Button deleteButton =
                this.Controls.AddButton(25, 75, 80, 30, "deleteButton");
            deleteButton.Text = "Click to delete";
            deleteButton.Click += new EventHandler(deleteButton_Click);
        }

        // Delete the clicked button.
        void deleteButton_Click(object sender, EventArgs e)
        {
            Microsoft.Office.Tools.Excel.Controls.Button clickedButton =
                (Microsoft.Office.Tools.Excel.Controls.Button)sender;

            clickedButton.Delete();
        }

.NET Framework 보안

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

참고 항목

참조

Button 클래스

Microsoft.Office.Tools.Excel.Controls 네임스페이스