#if NET_2_0
using System.Collections;
+using System.ComponentModel;
namespace System.Windows.Forms {
+ [ListBindable (false)]
public class DataGridViewSelectedRowCollection : BaseCollection, IList, ICollection, IEnumerable {
+ private DataGridView dataGridView;
+
+ internal DataGridViewSelectedRowCollection (DataGridView dataGridView)
+ {
+ this.dataGridView = dataGridView;
+ }
- public bool IsFixedSize {
+ bool IList.IsFixedSize {
get { return base.List.IsFixedSize; }
}
get { return (DataGridViewRow) base.List[index]; }
}
- public int Add (object o) {
+ int IList.Add (object o)
+ {
throw new NotSupportedException("Can't add elements to this collection.");
}
-
- public void Clear () {
+
+ void IList.Clear ()
+ {
+ Clear ();
+ }
+
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public void Clear ()
+ {
throw new NotSupportedException("This collection cannot be cleared.");
}
- public bool Contains (object o) {
+ bool IList.Contains (object o)
+ {
return Contains(o as DataGridViewRow);
}
- public bool Contains (DataGridViewRow dataGridViewRow) {
+ public bool Contains (DataGridViewRow dataGridViewRow)
+ {
return base.List.Contains(dataGridViewRow);
}
- public void CopyTo (DataGridViewRow[] array, int index) {
+ public void CopyTo (DataGridViewRow[] array, int index)
+ {
base.List.CopyTo(array, index);
}
- public int IndexOf (object o) {
+ int IList.IndexOf (object o)
+ {
return base.List.IndexOf(o);
}
- public void Insert (int index, object o) {
+ void IList.Insert (int index, object o)
+ {
Insert(index, o as DataGridViewRow);
}
- public void Insert (int index, DataGridViewRow dataGridViewRow) {
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public void Insert (int index, DataGridViewRow dataGridViewRow)
+ {
throw new NotSupportedException("Insert is not allowed.");
}
- public void Remove (object o) {
+ void IList.Remove (object o)
+ {
throw new NotSupportedException("Can't remove elements of this collection.");
}
- public void RemoveAt (int index) {
+ void IList.RemoveAt (int index)
+ {
throw new NotSupportedException("Can't remove elements of this collection.");
}
get { return base.List; }
}
- internal void InternalAdd (DataGridViewRow dataGridViewRow) {
+ internal void InternalAdd (DataGridViewRow dataGridViewRow)
+ {
base.List.Add(dataGridViewRow);
}
-
- internal void InternalRemove (DataGridViewRow dataGridViewRow) {
+
+ internal void InternalAddRange (DataGridViewSelectedRowCollection rows)
+ {
+ if (rows == null)
+ return;
+
+ // Believe it or not, MS adds the rows in reverse order...
+ DataGridViewRow editing_row = dataGridView != null ? dataGridView.EditingRow : null;
+ for (int i = rows.Count - 1; i >= 0; i--) {
+ if (rows [i] == editing_row)
+ continue;
+ base.List.Add (rows [i]);
+ }
+ }
+
+ internal void InternalRemove (DataGridViewRow dataGridViewRow)
+ {
base.List.Remove(dataGridViewRow);
}