CancelEventArgs.Cancel プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > CancelEventArgs.Cancel プロパティの意味・解説 

CancelEventArgs.Cancel プロパティ

イベントキャンセルするかどうかを示す値を取得または設定します

名前空間: System.ComponentModel
アセンブリ: System (system.dll 内)
構文構文

使用例使用例

CancelEventArgs と CancelEventHandler を使用してFormClosing イベント処理する例を次に示します。このコードは、クラス レベルBoolean 変数 isDataSaved を持つ Form作成されていることを前提にしています。また、OtherInitialize メソッドフォームLoad メソッドまたはコンストラクタから (InitializeComponent呼び出し後で) 起動するためのステートメント追加されていることも前提にしています。

' Call this method from the Load method of your form.
Private Sub OtherInitialize()
    ' Exchange commented line and note the difference.
    Me.isDataSaved = True
    'Me.isDataSaved = False
End Sub 'OtherInitialize

Private Sub Form1_Closing(sender As
 Object, e As _
   System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
    If Not isDataSaved Then
        e.Cancel = True
        MessageBox.Show("You must save first.")
    Else
        e.Cancel = False
        MessageBox.Show("Goodbye.")
    End If
End Sub 'Form1_Closing
// 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.");
       }
    }
 
private:
   // Call this method from the InitializeComponent() method of your
 form
   void OtherInitialize()
   {
      this->Closing += gcnew CancelEventHandler( this,
 &Form1::Form1_Cancel );
      this->myDataIsSaved = true;
   }

   void Form1_Cancel( Object^ /*sender*/, CancelEventArgs^ e )
   {
      if ( !myDataIsSaved )
      {
         e->Cancel = true;
         MessageBox::Show( "You must save first." );
      }
      else
      {
         e->Cancel = false;
         MessageBox::Show( "Goodbye." );
      }
   }
// Calls this method from the InitializeComponent() method of your form
private void OtherInitialize()
{
    this.add_Closing(new CancelEventHandler(this.Form1_Cancel));
    this.myDataIsSaved = (boolean)new System.Boolean();
    this.myDataIsSaved = true;
} //OtherInitialize

protected void Form1_Cancel(Object sender,
 CancelEventArgs e)
{
    if (!(myDataIsSaved)) {
        e.set_Cancel(true);
        MessageBox.Show("You must save first.");
    }
    else {
        e.set_Cancel(false);
        MessageBox.Show("Goodbye.");
    }
} //Form1_Cancel
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からCancelEventArgs.Cancel プロパティを検索した結果を表示しています。
Weblioに収録されているすべての辞書からCancelEventArgs.Cancel プロパティを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からCancelEventArgs.Cancel プロパティ を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「CancelEventArgs.Cancel プロパティ」の関連用語

CancelEventArgs.Cancel プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



CancelEventArgs.Cancel プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS