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 ()
99 public DataView CreateChildView (DataRelation relation)
101 if (relation == null)
102 throw new ArgumentException ("The relation is not parented to the table.");
103 return new DataView (relation.ChildTable);
106 public DataView CreateChildView (string name)
108 return CreateChildView (
109 dataRow.Table.ChildRelations [name]);
113 public void Delete ()
115 throw new NotImplementedException ();
119 public void EndEdit ()
126 #endregion // Methods
130 public DataView DataView
152 [System.Runtime.CompilerServices.IndexerName("Item")]
153 public object this[string column] {
156 DataColumn dc = dataView.Table.Columns[column];
161 DataColumn dc = dataView.Table.Columns[column];
163 dataView.ChangedList(ListChangedType.ItemChanged,dc.Ordinal,-1);
167 // the compiler creates a DefaultMemeberAttribute from
168 // this IndexerNameAttribute
169 public object this[int column] {
172 DataColumn dc = dataView.Table.Columns[column];
177 DataColumn dc = dataView.Table.Columns[column];
190 public DataRowVersion RowVersion {
198 public override int GetHashCode() {
199 throw new NotImplementedException ();
202 #endregion // Properties
204 #region ICustomTypeDescriptor implementations
207 AttributeCollection ICustomTypeDescriptor.GetAttributes ()
209 System.ComponentModel.AttributeCollection attributes;
210 attributes = AttributeCollection.Empty;
215 string ICustomTypeDescriptor.GetClassName ()
221 string ICustomTypeDescriptor.GetComponentName ()
227 TypeConverter ICustomTypeDescriptor.GetConverter ()
233 EventDescriptor ICustomTypeDescriptor.GetDefaultEvent ()
239 PropertyDescriptor ICustomTypeDescriptor.GetDefaultProperty ()
245 object ICustomTypeDescriptor.GetEditor (Type editorBaseType)
251 EventDescriptorCollection ICustomTypeDescriptor.GetEvents ()
253 return new EventDescriptorCollection(null);
257 EventDescriptorCollection ICustomTypeDescriptor.GetEvents (Attribute [] attributes)
259 return new EventDescriptorCollection(null);
263 PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties ()
265 ITypedList typedList = (ITypedList) dataView;
266 return typedList.GetItemProperties(new PropertyDescriptor[0]);
270 PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties (Attribute [] attributes)
272 PropertyDescriptorCollection descriptors;
273 descriptors = ((ICustomTypeDescriptor) this).GetProperties ();
274 // TODO: filter out descriptors which do not contain
275 // any of those attributes
276 // except, those descriptors
277 // that contain DefaultMemeberAttribute
282 object ICustomTypeDescriptor.GetPropertyOwner (PropertyDescriptor pd)
287 #endregion // ICustomTypeDescriptor implementations
289 #region IDataErrorInfo implementation
291 string IDataErrorInfo.Error {
298 string IDataErrorInfo.this[string columnName] {
305 #endregion // IDataErrorInfo implementation