private ListViewItem FindItem(bool isTextSearch, string text, bool isPrefixSearch, Point pt, SearchDirectionHint dir, int startIndex, bool includeSubItemsInSearch) { if (this.Items.Count != 0) { if (!base.IsHandleCreated) { this.CreateHandle(); } if (this.VirtualMode) { SearchForVirtualItemEventArgs e = new SearchForVirtualItemEventArgs(isTextSearch, isPrefixSearch, includeSubItemsInSearch, text, pt, dir, startIndex); this.OnSearchForVirtualItem(e); if (e.Index != -1) { return this.Items[e.Index]; } return null; } System.Windows.Forms.NativeMethods.LVFINDINFO lParam = new System.Windows.Forms.NativeMethods.LVFINDINFO(); if (isTextSearch) { lParam.flags = 2; lParam.flags |= isPrefixSearch ? 8 : 0; lParam.psz = text; } else { lParam.flags = 0x40; lParam.ptX = pt.X; lParam.ptY = pt.Y; lParam.vkDirection = (int) dir; } lParam.lParam = IntPtr.Zero; int num = (int) System.Windows.Forms.UnsafeNativeMethods.SendMessage(new HandleRef(this, base.Handle), System.Windows.Forms.NativeMethods.LVM_FINDITEM, startIndex - 1, ref lParam); if (num >= 0) { return this.Items[num]; } if (isTextSearch && includeSubItemsInSearch) { for (int i = startIndex; i < this.Items.Count; i++) { ListViewItem item = this.Items[i]; for (int j = 0; j < item.SubItems.Count; j++) { ListViewItem.ListViewSubItem item2 = item.SubItems[j]; if (string.Equals(text, item2.Text, StringComparison.OrdinalIgnoreCase)) { return item; } if (isPrefixSearch && CultureInfo.CurrentCulture.CompareInfo.IsPrefix(item2.Text, text, CompareOptions.IgnoreCase)) { return item; } } } } } return null; }
internal int GetDisplayIndex(ListViewItem item, int lastIndex) { this.ApplyUpdateCachedItems(); if (base.IsHandleCreated && !this.ListViewHandleDestroyed) { System.Windows.Forms.NativeMethods.LVFINDINFO lParam = new System.Windows.Forms.NativeMethods.LVFINDINFO { lParam = (IntPtr) item.ID, flags = 1 }; int num = -1; if (lastIndex != -1) { num = (int) System.Windows.Forms.UnsafeNativeMethods.SendMessage(new HandleRef(this, base.Handle), System.Windows.Forms.NativeMethods.LVM_FINDITEM, lastIndex - 1, ref lParam); } if (num == -1) { num = (int) System.Windows.Forms.UnsafeNativeMethods.SendMessage(new HandleRef(this, base.Handle), System.Windows.Forms.NativeMethods.LVM_FINDITEM, -1, ref lParam); } return num; } int num2 = 0; foreach (object obj2 in this.listItemsArray) { if (obj2 == item) { return num2; } num2++; } return -1; }