CancelEventArgsとは? わかりやすく解説

CancelEventArgs クラス

キャンセルできるイベントデータ提供します

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

Public Class CancelEventArgs
    Inherits EventArgs
Dim instance As CancelEventArgs
public class CancelEventArgs : EventArgs
public ref class CancelEventArgs : public
 EventArgs
public class CancelEventArgs extends EventArgs
public class CancelEventArgs extends
 EventArgs
解説解説
使用例使用例

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
継承階層継承階層
System.Object
   System.EventArgs
    System.ComponentModel.CancelEventArgs
       派生クラス
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
CancelEventArgs メンバ
System.ComponentModel 名前空間
CancelEventHandler

CancelEventArgs コンストラクタ ()


CancelEventArgs コンストラクタ


CancelEventArgs コンストラクタ (Boolean)


CancelEventArgs プロパティ


CancelEventArgs メソッド


CancelEventArgs メンバ

キャンセルできるイベントデータ提供します

CancelEventArgs データ型公開されるメンバを以下の表に示します


パブリック コンストラクタパブリック コンストラクタ
パブリック プロパティパブリック プロパティ
パブリック メソッドパブリック メソッド
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

CancelEventArgs クラス
System.ComponentModel 名前空間
CancelEventHandler



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

辞書ショートカット

すべての辞書の索引

「CancelEventArgs」の関連用語

CancelEventArgsのお隣キーワード
検索ランキング

   

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



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

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

©2024 GRAS Group, Inc.RSS