+2007-12-19 Carlos Alberto Cortez <calberto.cortez@gmail.com>
+
+ * ListBox.cs: Both FindString and FindStringExact methods must do an
+ case insensitive search, should allow the last valid index to be
+ passed in the overload taking an initial index, and should also
+ continue searching from the top back to the specified index when it
+ reaches the bottom.
+
2007-12-19 Jonathan Pobst <monkey@jpobst.com>
* TextControl.cs: Apply patch from Luke Page that fixes a scrolling
using System.ComponentModel;
using System.ComponentModel.Design;
using System.ComponentModel.Design.Serialization;
+using System.Globalization;
using System.Reflection;
using System.Runtime.InteropServices;
if (Items.Count == 0)
return -1; // No exception throwing if empty
- if (startIndex < -1 || startIndex >= Items.Count - 1)
+ if (startIndex < -1 || startIndex >= Items.Count)
throw new ArgumentOutOfRangeException ("Index of out range");
- startIndex++;
- for (int i = startIndex; i < Items.Count; i++) {
- if ((GetItemText (Items[i])).StartsWith (s))
+ startIndex = (startIndex == Items.Count - 1) ? 0 : startIndex + 1;
+
+ int i = startIndex;
+ while (true) {
+ string text = GetItemText (Items [i]);
+ if (CultureInfo.CurrentCulture.CompareInfo.IsPrefix (text, s,
+ CompareOptions.IgnoreCase))
return i;
+
+ i = (i == Items.Count - 1) ? 0 : i + 1;
+ if (i == startIndex)
+ break;
}
return NoMatches;
if (Items.Count == 0)
return -1; // No exception throwing if empty
- if (startIndex < -1 || startIndex >= Items.Count - 1)
+ if (startIndex < -1 || startIndex >= Items.Count)
throw new ArgumentOutOfRangeException ("Index of out range");
- startIndex++;
- for (int i = startIndex; i < Items.Count; i++) {
- if ((GetItemText (Items[i])).Equals (s))
+ startIndex = (startIndex + 1 == Items.Count) ? 0 : startIndex + 1;
+
+ int i = startIndex;
+ while (true) {
+ if (String.Compare (GetItemText (Items[i]), s, true) == 0)
return i;
+
+ i = (i + 1 == Items.Count) ? 0 : i + 1;
+ if (i == startIndex)
+ break;
}
return NoMatches;