Advertisement
MBrendecke

Static Events

Dec 31st, 2016
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.74 KB | None | 0 0
  1. using System;
  2. using System.Windows.Forms;
  3.  
  4. namespace GUI {
  5.   static public class Raiser {
  6.     static public event EventHandler<EventArgs> StatusChanged = null;
  7.     static public void StateChanged (object sender, EventArgs e) => StatusChanged?.Invoke(sender, e);
  8.   }
  9.  
  10.   class Form1 : Form {
  11.     private CheckBox chkTest = new CheckBox();
  12.  
  13.     public Form1() {
  14.       chkTest.StateChanged += CheckboxStateCghanged;
  15.     }
  16.  
  17.     private void CheckboxStateChanged() {
  18.       Raiser.StateChanged(this, new CheckboxEventArgs(this.chkTest));
  19.     }
  20.   }
  21.  
  22.   class CheckboxEventArgs : EventArgs {
  23.     public CheckBox CheckBox { get; protected set; }
  24.  
  25.     public CheckBoxEventArgs(CheckBox checkbox) {
  26.       this.CheckBox = checkbox;
  27.     }
  28.   }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement