private void m_searchEngine_SearchCompleted(object sender, SearchCompletedEventArgs e) { UpdateResults(e.Fields.FirstOrDefault(), e.Results); // On the completion of a new search set the selection to the first result without stealing the focus // from any other controls. if (m_bvMatches.BrowseView.IsHandleCreated) // hotfix paranoia test { var oldEnabledState = m_bvMatches.Enabled; m_bvMatches.Enabled = false; // disable the control before changing the selection so that the focus won't change m_bvMatches.SelectedIndex = m_bvMatches.AllItems.Count > 0 ? 0 : -1; m_bvMatches.Enabled = oldEnabledState; // restore the control to it's previous enabled state } }
private void m_searchEngine_SearchCompleted(object sender, SearchCompletedEventArgs e) { UpdateResults(e.Fields.FirstOrDefault(), e.Results); // On the completion of a new search set the selection to the first result without stealing the focus // from any other controls. if(m_bvMatches.BrowseView.IsHandleCreated) // hotfix paranoia test { var oldEnabledState = m_bvMatches.Enabled; m_bvMatches.Enabled = false; // disable the control before changing the selection so that the focus won't change m_bvMatches.SelectedIndex = m_bvMatches.AllItems.Count > 0 ? 0 : -1; m_bvMatches.Enabled = oldEnabledState; // restore the control to it's previous enabled state } }