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
12 // Permission is hereby granted, free of charge, to any person obtaining
13 // a copy of this software and associated documentation files (the
14 // "Software"), to deal in the Software without restriction, including
15 // without limitation the rights to use, copy, modify, merge, publish,
16 // distribute, sublicense, and/or sell copies of the Software, and to
17 // permit persons to whom the Software is furnished to do so, subject to
18 // the following conditions:
20 // The above copyright notice and this permission notice shall be
21 // included in all copies or substantial portions of the Software.
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 using System
.Collections
;
33 using System
.ComponentModel
;
35 namespace System
.Windows
.Forms
{
38 /// Represents a collection of Binding objects for a control.
42 public class BindingsCollection
: BaseCollection
{
45 protected internal BindingsCollection ()
50 // --- public and protected Properties ---
51 public override int Count
{
57 public Binding
this[int index
] {
59 return (Binding
)(base.List
[index
]);
64 protected override ArrayList List
{
70 // --- public Methods ---
72 protected virtual void AddCore(Binding dataBinding
) {
76 protected virtual void ClearCore(){
80 protected virtual void RemoveCore(Binding dataBinding
){
84 // CollectionChanged event:
85 // Though it was not documented, here methods Add and Remove
86 // cause the CollectionChanged event to occur, similarily as Clear.
87 // Would be nice if someone checked the exact event behavior of .NET implementation.
89 protected internal void Add(Binding binding
)
91 base.List
.Add(binding
);
92 OnCollectionChanged(new CollectionChangeEventArgs(
93 CollectionChangeAction
.Add
,
98 protected internal void Clear()
101 OnCollectionChanged(new CollectionChangeEventArgs(
102 CollectionChangeAction
.Refresh
,
107 protected virtual void OnCollectionChanged(CollectionChangeEventArgs ccevent
)
109 if (CollectionChanged
!= null)
110 CollectionChanged(this, ccevent
);
113 protected internal void Remove(Binding binding
)
115 base.List
.Remove(binding
);
116 OnCollectionChanged(new CollectionChangeEventArgs(
117 CollectionChangeAction
.Remove
,
122 protected internal void RemoveAt(int index
)
124 base.List
.RemoveAt(index
);
125 OnCollectionChanged(new CollectionChangeEventArgs(
126 CollectionChangeAction
.Remove
,
131 protected internal bool ShouldSerializeMyAll()
133 if (this.Count
>0) return true;
138 public event CollectionChangeEventHandler CollectionChanged
;