ToolStripControlHost.OnUnsubscribeControlEvents(Control) 메서드

정의

호스팅된 컨트롤에서 발생하는 이벤트의 등록을 취소합니다.Unsubscribes events from the hosted control.

protected:
 virtual void OnUnsubscribeControlEvents(System::Windows::Forms::Control ^ control);
protected virtual void OnUnsubscribeControlEvents (System.Windows.Forms.Control control);
abstract member OnUnsubscribeControlEvents : System.Windows.Forms.Control -> unit
override this.OnUnsubscribeControlEvents : System.Windows.Forms.Control -> unit

매개 변수

control
Control

이벤트의 등록을 취소할 컨트롤입니다.The control from which to unsubscribe events.

예제

다음 코드 예제에는 호스트 된 컨트롤에서 노출 한 이벤트 구독을 취소 하는 방법을 보여 줍니다.The following code example demonstrates how to unsubscribe from an event exposed by the hosted control. 이 코드 예제는에 대해 제공 된 큰 예제의 일부는 ToolStripControlHost 클래스입니다.This code example is part of a larger example provided for the ToolStripControlHost class.

void OnUnsubscribeControlEvents( System::Windows::Forms::Control^ c )
{
   
   // Call the base method so the basic events are unsubscribed.
   __super::OnUnsubscribeControlEvents( c );
   
   // Cast the control to a MonthCalendar control.
   MonthCalendar^ monthCalendarControl = (MonthCalendar^)c;
   
   // Remove the event.
   monthCalendarControl->DateChanged -= gcnew DateRangeEventHandler( this, &ToolStripMonthCalendar::HandleDateChanged );
}
protected override void OnUnsubscribeControlEvents(Control c)
{
    // Call the base method so the basic events are unsubscribed.
    base.OnUnsubscribeControlEvents(c);

    // Cast the control to a MonthCalendar control.
    MonthCalendar monthCalendarControl = (MonthCalendar) c;

    // Remove the event.
    monthCalendarControl.DateChanged -=
        new DateRangeEventHandler(OnDateChanged);
}
Protected Overrides Sub OnUnsubscribeControlEvents(ByVal c As Control)
    ' Call the base method so the basic events are unsubscribed.
    MyBase.OnUnsubscribeControlEvents(c)

    ' Cast the control to a MonthCalendar control.
    Dim monthCalendarControl As MonthCalendar = _
        CType(c, MonthCalendar)

    ' Remove the event.
    RemoveHandler monthCalendarControl.DateChanged, _
        AddressOf HandleDateChanged

End Sub

설명

재정의 OnUnsubscribeControlEvents 이벤트를 구독 취소 방법 구독 OnSubscribeControlEvents합니다.Override the OnUnsubscribeControlEvents method to unsubscribe events subscribed in OnSubscribeControlEvents.

이벤트가 발생하면 대리자를 통해 이벤트 처리기가 호출됩니다.Raising an event invokes the event handler through a delegate. 자세한 내용은 이벤트 처리 및 발생합니다.For more information, see Handling and Raising Events.

또한 OnUnsubscribeControlEvents 메서드를 사용하면 파생 클래스가 대리자를 연결하지 않고도 이벤트를 처리할 수 있습니다.The OnUnsubscribeControlEvents method also allows derived classes to handle the event without attaching a delegate. 이는 파생 클래스에서 이벤트를 처리하는 기본 방법입니다.This is the preferred technique for handling the event in a derived class.

상속자 참고

파생 클래스에서 OnUnsubscribeControlEvents(Control)를 재정의하는 경우 등록된 대리자가 이벤트를 받도록 기본 클래스의 OnUnsubscribeControlEvents(Control) 메서드를 호출해야 합니다.When overriding OnUnsubscribeControlEvents(Control) in a derived class, be sure to call the base class's OnUnsubscribeControlEvents(Control) method so that registered delegates receive the event.

적용 대상