2 // System.Windows.Forms.BindingsCollection.cs
5 // stubbed out by Jaak Simm (jaaksimm@firm.ee)
6 // Dennis Hayes (dennish@Raytek.com)
8 // (C) 2002/3 Ximian, Inc
11 using System.Collections;
12 using System.ComponentModel;
14 namespace System.Windows.Forms {
17 /// Represents a collection of Binding objects for a control.
21 public class BindingsCollection : BaseCollection {
24 protected internal BindingsCollection ()
29 // --- public and protected Properties ---
30 public override int Count {
36 public Binding this[int index] {
38 return (Binding)(base.List[index]);
43 protected override ArrayList List {
49 // --- public Methods ---
51 protected virtual void AddCore(Binding dataBinding) {
55 protected virtual void ClearCore(){
59 protected virtual void RemoveCore(Binding dataBinding){
63 // CollectionChanged event:
64 // Though it was not documented, here methods Add and Remove
65 // cause the CollectionChanged event to occur, similarily as Clear.
66 // Would be nice if someone checked the exact event behavior of .NET implementation.
68 protected internal void Add(Binding binding)
70 base.List.Add(binding);
71 OnCollectionChanged(new CollectionChangeEventArgs(
72 CollectionChangeAction.Add,
77 protected internal void Clear()
80 OnCollectionChanged(new CollectionChangeEventArgs(
81 CollectionChangeAction.Refresh,
86 protected virtual void OnCollectionChanged(CollectionChangeEventArgs ccevent)
88 if (CollectionChanged != null)
89 CollectionChanged(this, ccevent);
92 protected internal void Remove(Binding binding)
94 base.List.Remove(binding);
95 OnCollectionChanged(new CollectionChangeEventArgs(
96 CollectionChangeAction.Remove,
101 protected internal void RemoveAt(int index)
103 base.List.RemoveAt(index);
104 OnCollectionChanged(new CollectionChangeEventArgs(
105 CollectionChangeAction.Remove,
110 protected internal bool ShouldSerializeMyAll()
112 if (this.Count>0) return true;
117 public event CollectionChangeEventHandler CollectionChanged;