Author: calberto
Date: 2007-08-20 15:05:52 -0400 (Mon, 20 Aug 2007)
New Revision: 84487
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListViewGroupCollection.cs
Log:
2007-08-20 Carlos Alberto Cortez <[EMAIL PROTECTED]>
* ListViewGroupCollection.cs: Make the string indexer use
the int based indexer to re-use code, instead of duplicate the code.
Also Redraw as needed and take into account null values.
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2007-08-20 18:49:52 UTC (rev 84486)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2007-08-20 19:05:52 UTC (rev 84487)
@@ -1,3 +1,9 @@
+2007-08-20 Carlos Alberto Cortez <[EMAIL PROTECTED]>
+
+ * ListViewGroupCollection.cs: Make the string indexer use
+ the int based indexer to re-use code, instead of duplicate the code.
+ Also Redraw as needed and take into account null values.
+
2007-08-20 Jonathan Pobst <[EMAIL PROTECTED]>
* StatusStrip.cs: Make sure the item's parent gets set in
SetDisplayedItems.
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListViewGroupCollection.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListViewGroupCollection.cs
2007-08-20 18:49:52 UTC (rev 84486)
+++
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListViewGroupCollection.cs
2007-08-20 19:05:52 UTC (rev 84487)
@@ -228,37 +228,47 @@
if (list.Count <= index || index < 0)
throw new
ArgumentOutOfRangeException("index");
- if (!Contains(value)) {
- CheckListViewItemsInGroup(value);
- list[index] = value;
-
- if (list_view_owner != null)
- list_view_owner.Redraw(true);
+ if (Contains (value))
+ return;
+
+ if (value != null) {
+ CheckListViewItemsInGroup (value);
+ value.ListViewOwner = list_view_owner;
}
+
+ list [index] = value;
+
+ if (list_view_owner != null)
+ list_view_owner.Redraw(true);
}
}
- public ListViewGroup this[string key] {
+ public ListViewGroup this [string key] {
get {
- foreach (ListViewGroup item in list)
- {
- if (item.Name.Equals(key))
- return item;
- }
+ int idx = IndexOfKey (key);
+ if (idx != -1)
+ return this [idx];
return null;
}
set {
- for(int i = 0; i < list.Count; i++)
- {
- if ((this[i].Name != null) &&
(this[i].Name.Equals(key))) {
- this[i] = value;
- break;
- }
- }
+ int idx = IndexOfKey (key);
+ if (idx == -1)
+ return;
+
+ this [idx] = value;
}
}
+ int IndexOfKey (string key)
+ {
+ for (int i = 0; i < list.Count; i++)
+ if (list [i].Name == key)
+ return i;
+
+ return -1;
+ }
+
#endregion
public void AddRange(ListViewGroup[] groups)
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches