**** Merged from MCS ****
[mono-project.git] / mcs / class / System.Windows.Forms / System.Windows.Forms / BindingsCollection.cs
blob2ed536f40197437f5b9e94e1c111beb30403056d
1 //
2 // System.Windows.Forms.BindingsCollection.cs
3 //
4 // Author:
5 // stubbed out by Jaak Simm (jaaksimm@firm.ee)
6 // Dennis Hayes (dennish@Raytek.com)
7 //
8 // (C) 2002/3 Ximian, Inc
9 //
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:
19 //
20 // The above copyright notice and this permission notice shall be
21 // included in all copies or substantial portions of the Software.
22 //
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 {
37 /// <summary>
38 /// Represents a collection of Binding objects for a control.
39 ///
40 /// </summary>
42 public class BindingsCollection : BaseCollection {
44 #region Constructors
45 protected internal BindingsCollection ()
48 #endregion
50 // --- public and protected Properties ---
51 public override int Count {
52 get {
53 return base.Count;
57 public Binding this[int index] {
58 get {
59 return (Binding)(base.List[index]);
63 [MonoTODO]
64 protected override ArrayList List {
65 get {
66 return base.List;
70 // --- public Methods ---
71 [MonoTODO]
72 protected virtual void AddCore(Binding dataBinding) {
75 [MonoTODO]
76 protected virtual void ClearCore(){
79 [MonoTODO]
80 protected virtual void RemoveCore(Binding dataBinding){
83 //
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,
94 base.List
95 ));
98 protected internal void Clear()
100 base.List.Clear();
101 OnCollectionChanged(new CollectionChangeEventArgs(
102 CollectionChangeAction.Refresh,
103 base.List
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,
118 base.List
122 protected internal void RemoveAt(int index)
124 base.List.RemoveAt(index);
125 OnCollectionChanged(new CollectionChangeEventArgs(
126 CollectionChangeAction.Remove,
127 base.List
131 protected internal bool ShouldSerializeMyAll()
133 if (this.Count>0) return true;
134 else return false;
137 // public events
138 public event CollectionChangeEventHandler CollectionChanged;