public Exception FindItemsWithText(string regexPattern) { try { ListViewItemBase selectItem = null; BeginUpdate(); Regex regex = new Regex(regexPattern, RegexOptions.Compiled | RegexOptions.Singleline | RegexOptions.CultureInvariant | RegexOptions.IgnoreCase); foreach (ListViewItemBase lvib in Items) { bool contains = lvib.Contains(regex); lvib.SearchResult = contains; if ((selectItem == null) && contains) { selectItem = lvib; } } Sort(); selectItem?.RefreshAndSelect(); RefreshGroupsHeader(); return(null); } catch (Exception e) { return(e); } finally { EndUpdate(); } }
private void AddOrReplaceItemInListView(ListViewItemBase newItem, ListViewItemBase oldItem = null) { try { uxListViewSecrets.BeginUpdate(); if (null != oldItem) { uxListViewSecrets.Items.Remove(oldItem); // Rename flow } uxListViewSecrets.AddOrReplaceItem(newItem); // Overwrite flow uxTimerSearchTextTypingCompleted_Tick(null, EventArgs.Empty); // Refresh search newItem?.RefreshAndSelect(); uxListViewSecrets.RefreshGroupsHeader(); RefreshItemsCount(); } finally { uxListViewSecrets.EndUpdate(); } }