Author: calberto
Date: 2007-01-14 20:43:35 -0500 (Sun, 14 Jan 2007)
New Revision: 70998

Modified:
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListView.cs
Log:
2007-01-14  Carlos Alberto Cortez <[EMAIL PROTECTED]>

        * ListView.cs: Implement 2.0 FindItemWithText method.



Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2007-01-14 23:16:49 UTC (rev 70997)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2007-01-15 01:43:35 UTC (rev 70998)
@@ -1,3 +1,7 @@
+2007-01-14  Carlos Alberto Cortez <[EMAIL PROTECTED]>
+
+       * ListView.cs: Implement 2.0 FindItemWithText method.
+
 2007-01-11  Everaldo Canuto  <[EMAIL PROTECTED]>
 
        * Form.cs: When process WM_NCCALCSIZE message use ClienSize.Width

Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListView.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListView.cs      
2007-01-14 23:16:49 UTC (rev 70997)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListView.cs      
2007-01-15 01:43:35 UTC (rev 70998)
@@ -2362,6 +2362,50 @@
                        else if (bounds.Bottom > view_rect.Bottom)
                                v_scroll.Value += (bounds.Bottom - 
view_rect.Bottom);
                }
+
+#if NET_2_0
+               public ListViewItem FindItemWithText (string text)
+               {
+                       if (items.Count == 0)
+                               return null;
+
+                       return FindItemWithText (text, true, 0, true);
+               }
+
+               public ListViewItem FindItemWithText (string text, bool 
includeSubItems, int startIndex)
+               {
+                       return FindItemWithText (text, includeSubItems, 
startIndex, true);
+               }
+
+               public ListViewItem FindItemWithText (string text, bool 
includeSubItems, int startIndex, bool prefixSearch)
+               {
+                       if (startIndex < 0 || startIndex >= items.Count)
+                               throw new ArgumentOutOfRangeException 
("startIndex");
+
+                       if (text == null)
+                               throw new ArgumentNullException ("text");
+
+                       for (int i = startIndex; i < items.Count; i++) {
+                               ListViewItem lvi = items [i];
+
+                               if ((prefixSearch && lvi.Text.StartsWith (text, 
true, CultureInfo.CurrentCulture)) // prefix search
+                                               || String.Compare (lvi.Text, 
text, true) == 0) // match
+                                       return lvi;
+                       }
+
+                       if (includeSubItems) {
+                               for (int i = startIndex; i < items.Count; i++) {
+                                       ListViewItem lvi = items [i];
+                                       foreach (ListViewItem.ListViewSubItem 
sub_item in lvi.SubItems)
+                                               if ((prefixSearch && 
sub_item.Text.StartsWith (text, true, CultureInfo.CurrentCulture))
+                                                               || 
String.Compare (sub_item.Text, text, true) == 0)
+                                                       return lvi;
+                               }
+                       }
+
+                       return null;
+               }
+#endif
                
                public ListViewItem GetItemAt (int x, int y)
                {

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to