2 // System.Data.DataRowView.cs
5 // Rodrigo Moya <rodrigo@ximian.com>
6 // Miguel de Icaza <miguel@ximian.com>
7 // Daniel Morgan <danmorg@sc.rr.com>
9 // (C) Ximian, Inc 2002
10 // (C) Daniel Morgan 2002
14 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
16 // Permission is hereby granted, free of charge, to any person obtaining
17 // a copy of this software and associated documentation files (the
18 // "Software"), to deal in the Software without restriction, including
19 // without limitation the rights to use, copy, modify, merge, publish,
20 // distribute, sublicense, and/or sell copies of the Software, and to
21 // permit persons to whom the Software is furnished to do so, subject to
22 // the following conditions:
24 // The above copyright notice and this permission notice shall be
25 // included in all copies or substantial portions of the Software.
27 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
28 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
29 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
30 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
31 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
32 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
33 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
37 using System
.Collections
;
38 using System
.ComponentModel
;
39 using System
.Reflection
;
44 /// Represents a customized view of a DataRow exposed as a fully featured Windows Forms control.
46 public class DataRowView
: ICustomTypeDescriptor
, IEditableObject
, IDataErrorInfo
52 DataRowVersion rowVersion
= DataRowVersion
.Default
;
54 // FIXME: what are the defaults?
62 internal DataRowView (DataView dataView
, DataRow row
) : this(dataView
, row
, false){
65 internal DataRowView (DataView dataView
, DataRow row
, bool isNew
) {
66 this.dataView
= dataView
;
71 #endregion // Constructors
75 public override bool Equals(object other
)
77 return (other
!= null &&
78 other
is DataRowView
&&
79 ((DataRowView
)other
).dataRow
!= null &&
80 ((DataRowView
)other
).dataRow
.Equals(this.dataRow
));
84 public void BeginEdit ()
92 public void CancelEdit ()
100 public DataView
CreateChildView (DataRelation relation
)
102 throw new NotImplementedException ();
106 public DataView
CreateChildView (string name
)
108 throw new NotImplementedException ();
112 public void Delete ()
114 throw new NotImplementedException ();
118 public void EndEdit ()
125 #endregion // Methods
129 public DataView DataView
151 [System
.Runtime
.CompilerServices
.IndexerName("Item")]
152 public object this[string column
] {
155 DataColumn dc
= dataView
.Table
.Columns
[column
];
160 DataColumn dc
= dataView
.Table
.Columns
[column
];
162 dataView
.ChangedList(ListChangedType
.ItemChanged
,dc
.Ordinal
,-1);
166 // the compiler creates a DefaultMemeberAttribute from
167 // this IndexerNameAttribute
168 public object this[int column
] {
171 DataColumn dc
= dataView
.Table
.Columns
[column
];
176 DataColumn dc
= dataView
.Table
.Columns
[column
];
189 public DataRowVersion RowVersion
{
197 public override int GetHashCode() {
198 throw new NotImplementedException ();
201 #endregion // Properties
203 #region ICustomTypeDescriptor implementations
206 AttributeCollection ICustomTypeDescriptor
.GetAttributes ()
208 System
.ComponentModel
.AttributeCollection attributes
;
209 attributes
= AttributeCollection
.Empty
;
214 string ICustomTypeDescriptor
.GetClassName ()
220 string ICustomTypeDescriptor
.GetComponentName ()
226 TypeConverter ICustomTypeDescriptor
.GetConverter ()
232 EventDescriptor ICustomTypeDescriptor
.GetDefaultEvent ()
238 PropertyDescriptor ICustomTypeDescriptor
.GetDefaultProperty ()
244 object ICustomTypeDescriptor
.GetEditor (Type editorBaseType
)
250 EventDescriptorCollection ICustomTypeDescriptor
.GetEvents ()
252 return new EventDescriptorCollection(null);
256 EventDescriptorCollection ICustomTypeDescriptor
.GetEvents (Attribute
[] attributes
)
258 return new EventDescriptorCollection(null);
262 PropertyDescriptorCollection ICustomTypeDescriptor
.GetProperties ()
264 ITypedList typedList
= (ITypedList
) dataView
;
265 return typedList
.GetItemProperties(new PropertyDescriptor
[0]);
269 PropertyDescriptorCollection ICustomTypeDescriptor
.GetProperties (Attribute
[] attributes
)
271 PropertyDescriptorCollection descriptors
;
272 descriptors
= ((ICustomTypeDescriptor
) this).GetProperties ();
273 // TODO: filter out descriptors which do not contain
274 // any of those attributes
275 // except, those descriptors
276 // that contain DefaultMemeberAttribute
281 object ICustomTypeDescriptor
.GetPropertyOwner (PropertyDescriptor pd
)
286 #endregion // ICustomTypeDescriptor implementations
288 #region IDataErrorInfo implementation
290 string IDataErrorInfo
.Error
{
297 string IDataErrorInfo
.this[string columnName
] {
304 #endregion // IDataErrorInfo implementation