이 문서는 기계로 번역한 것입니다. 원본 텍스트를 보려면 포인터를 문서의 문장 위로 올리십시오. 추가 정보
번역
원본
이 항목은 아직 평가되지 않았습니다.- 이 항목 평가

CancelEventArgs.Cancel 속성

이벤트를 취소해야 할지 여부를 나타내는 값을 가져오거나 설정합니다.

네임스페이스:  System.ComponentModel
어셈블리:  System(System.dll)
public bool Cancel { get; set; }

속성 값

형식: System.Boolean
이벤트를 취소해야 하면 true이고, 그렇지 않으면 false입니다.

다음 예제에서는 CancelEventArgsCancelEventHandler를 사용하여 FormFormClosing 이벤트를 처리합니다. 이 코드에서는 isDataSaved라는 클래스 수준의 Boolean 변수를 사용하여 Form을 만들었다고 가정합니다. 또한 InitializeComponent를 호출한 후 폼의 Load 메서드나 생성자에서 OtherInitialize 메서드를 호출하는 문을 추가했다고 가정합니다.


// Call this method from the constructor of your form
    private void OtherInitialize() {
       this.Closing += new CancelEventHandler(this.Form1_Closing);
       // Exchange commented line and note the difference.
       this.isDataSaved = true;
       //this.isDataSaved = false;
    }

    private void Form1_Closing(Object sender, CancelEventArgs e) {
       if (!isDataSaved) {
          e.Cancel = true;
          MessageBox.Show("You must save first.");
       }
       else {
          e.Cancel = false;
          MessageBox.Show("Goodbye.");
       }
    }
 


.NET Framework

4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0에서 지원

.NET Framework Client Profile

4, 3.5 SP1에서 지원

이식 가능한 클래스 라이브러리

이식 가능한 클래스 라이브러리에서 지원

Windows 스토어 앱용 .NET

Windows 8에서 지원

Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008(서버 코어 역할은 지원되지 않음), Windows Server 2008 R2(서버 코어 역할은 SP1 이상에서 지원, Itanium은 지원되지 않음)

.NET Framework에서 모든 플랫폼의 전체 버전을 지원하지는 않습니다. 지원되는 버전의 목록을 보려면 .NET Framework 시스템 요구 사항을 참조하십시오.
이 정보가 도움이 되었습니까?
(1500자 남음)

커뮤니티 추가 항목

추가
© 2013 Microsoft. All rights reserved.