// Editbox wordwheel private void indexTextBox_TextChanged(object sender, EventArgs e) //type kwText, word wheel down to the matching kwText { int iSelected = -1; if (indexListView.SelectedIndices.Count > 0) { iSelected = indexListView.SelectedIndices[0]; } String text = indexTextBox.Text.Trim(); if (_helpKeywords != null && _helpKeywords.Count > 0) { int i = 0; if (!String.IsNullOrEmpty(text)) { i = _helpKeywords.MoveToKeyword(text); } if (i >= 0 && i <= _helpKeywords.Count && i != iSelected) { //Select and scroll match into view indexListView.BeginUpdate(); /// This keeps selection traffic to a min try { indexListView.SelectedIndices.Clear(); indexListView.SelectedIndices.Add(i); indexListView.Items[i].EnsureVisible(); indexListView.TopItem = indexListView.Items[i]; } finally { indexListView.EndUpdate(); } } } }
private void SearchForText() { int iSelected = -1; if (keywordsListView.SelectedIndices.Count > 0) { iSelected = keywordsListView.SelectedIndices[0]; } String text = searchTextBox.Text.Trim(); if (_helpKeywords != null && _helpKeywords.Count > 0) { int i = 0; if (!String.IsNullOrEmpty(text)) { i = _helpKeywords.MoveToKeyword(text); } if (i >= 0 && i <= _helpKeywords.Count && i != iSelected) { //Select and scroll match into view keywordsListView.BeginUpdate(); /// This is really important on a Virtual List as we are doing several list changes. Will crash without it. try { keywordsListView.SelectedIndices.Clear(); keywordsListView.SelectedIndices.Add(i); keywordsListView.Items[i].EnsureVisible(); keywordsListView.TopItem = keywordsListView.Items[i]; } finally { keywordsListView.EndUpdate(); } } } }