Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- List<Controls> list = new List<Controls>
- myObject.myList.Add(new Control());
- myList.AddingEvent += HandleAddingEvent
- using System;
- using System.Collections.Generic;
- namespace test {
- class Program {
- class MyList<T> : List<T> {
- public event EventHandler OnAdd;
- public void Add(T item) {
- if (null != OnAdd) {
- OnAdd(this, null);
- }
- base.Add(item);
- }
- }
- static void Main(string[] args) {
- MyList<int> l = new MyList<int>();
- l.OnAdd += new EventHandler(l_OnAdd);
- l.Add(1);
- }
- static void l_OnAdd(object sender, EventArgs e) {
- Console.WriteLine("Element added...");
- }
- }
- }
- ObservableCollection<int> myList = new ObservableCollection<int>();
- myList.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(
- delegate(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
- {
- if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add)
- {
- MessageBox.Show("Added value");
- }
- }
- );
- myList.Add(1);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement