Author: calberto
Date: 2007-10-06 02:59:09 -0400 (Sat, 06 Oct 2007)
New Revision: 87026
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListView.cs
Log:
2007-10-06 Carlos Alberto Cortez <[EMAIL PROTECTED]>
* ListView.cs: In ListViewItemCollection, make Remove call RemoveAt,
instead of the opposite (RemoveAt call Remove). This is a better
approach since we don't need to to a pair of traversals when using
RemoveAt.
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2007-10-06 05:22:28 UTC (rev 87025)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2007-10-06 06:59:09 UTC (rev 87026)
@@ -1,3 +1,10 @@
+2007-10-06 Carlos Alberto Cortez <[EMAIL PROTECTED]>
+
+ * ListView.cs: In ListViewItemCollection, make Remove call RemoveAt,
+ instead of the opposite (RemoveAt call Remove). This is a better
+ approach since we don't need to to a pair of traversals when using
+ RemoveAt.
+
2006-10-05 Carlos Alberto Cortez <[EMAIL PROTECTED]>
* TreeView.cs: When Keys.Left is pressed, before trying to Collapse
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListView.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListView.cs
2007-10-06 05:22:28 UTC (rev 87025)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListView.cs
2007-10-06 06:59:09 UTC (rev 87026)
@@ -4823,16 +4823,31 @@
if (owner != null && owner.VirtualMode)
throw new InvalidOperationException ();
#endif
- if (!list.Contains (item))
- return;
+ int idx = list.IndexOf (item);
+ if (idx != -1)
+ RemoveAt (idx);
+ }
+
+ public virtual void RemoveAt (int index)
+ {
+ if (index < 0 || index >= Count)
+ throw new ArgumentOutOfRangeException
("index");
+
+#if NET_2_0
+ if (owner != null && owner.VirtualMode)
+ throw new InvalidOperationException ();
+#endif
+
+ ListViewItem item = (ListViewItem) list [index];
+
bool selection_changed = false;
if (is_main_collection && owner != null) {
- selection_changed =
owner.SelectedItems.Contains (item);
+ selection_changed =
owner.SelectedIndices.Contains (index);
owner.item_control.CancelEdit (item);
}
- list.Remove (item);
+ list.RemoveAt (index);
if (is_main_collection)
item.Owner = null;
@@ -4846,21 +4861,7 @@
owner.OnSelectedIndexChanged
(EventArgs.Empty);
}
- public virtual void RemoveAt (int index)
- {
- if (index < 0 || index >= Count)
- throw new ArgumentOutOfRangeException
("index");
-
#if NET_2_0
- if (owner != null && owner.VirtualMode)
- throw new InvalidOperationException ();
-#endif
-
- ListViewItem item = (ListViewItem) list [index];
- Remove (item);
- }
-
-#if NET_2_0
public virtual void RemoveByKey (string key)
{
int idx = IndexOfKey (key);
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches