Esempio n. 1
0
/*        #region private void SearchItem(string stringToSearch, int startIndex)
 *
 *      private void SearchItem(string stringToSearch, int startIndex)
 *      {
 *          ItemsListView.SelectedItems.Clear();
 *          if (searchStartIndex > ItemsListView.Items.Count - 1)
 *              return;
 *          ListViewItem item = ItemsListView.FindItemWithText(stringToSearch, true, startIndex);
 *          if (item != null)
 *          {
 *              item.Selected = true;
 *              ItemsListView.Focus();
 *              item.EnsureVisible();
 *              searchStartIndex = ItemsListView.Items.IndexOf(item) + 1;
 *              quickSearchControl.SuccessBackgroundColor = true;
 *          }
 *          else
 *          {
 *              quickSearchControl.SuccessBackgroundColor = false;
 *          }
 *      }
 *
 #endregion*///todo backup

        #region private void SearchItem(string stringToSearch)

        private void SearchItem(string stringToSearch)
        {
            int searchStartIndex = 0;

            ClearSelectedItems();
            ItemsListView.SelectedItems.Clear();
            List <ListViewItem> findItems = new List <ListViewItem>();
            ListViewItem        item      = ItemsListView.FindItemWithText(stringToSearch, true, searchStartIndex);

            while (item != null && searchStartIndex < ItemsListView.Items.Count)
            {
                item.Selected = true;
                findItems.Add(item);
                searchStartIndex = ItemsListView.Items.IndexOf(item) + 1;
                if (searchStartIndex >= ItemsListView.Items.Count)
                {
                    break;
                }
                item = ItemsListView.FindItemWithText(stringToSearch, true, searchStartIndex);
            }
            if (findItems.Count > 0)
            {
                ItemsListView.Focus();
                findItems[0].EnsureVisible();
                quickSearchControl.SuccessBackgroundColor = true;
            }
            else
            {
                quickSearchControl.SuccessBackgroundColor = false;
            }
        }