/// ------------------------------------------------------------------------------------ /// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// ------------------------------------------------------------------------------------ private void lvFindResult_ColumnClick(object sender, ColumnClickEventArgs e) { if (lvFindResult.Items.Count == 0) { return; } // Figure out what the new sort order should be based on the column clicked on. SortNamesBy newSortBy = SortNamesBy.kLangName; switch (e.Column) { case 0: newSortBy = SortNamesBy.kLangName; break; case 1: newSortBy = SortNamesBy.kCountryName; break; case 2: newSortBy = SortNamesBy.kEthnoCode; break; } // Don't bother reloading the data if the sort order didn't change. if (m_currentSortBy == newSortBy) { return; } m_currentSortBy = newSortBy; // Save the currently selected item. string langName = string.Empty; string country = string.Empty; string ethnoCode = string.Empty; if (lvFindResult.SelectedItems.Count > 0) { langName = lvFindResult.SelectedItems[0].Text; country = lvFindResult.SelectedItems[0].SubItems[1].Text; ethnoCode = lvFindResult.SelectedItems[0].SubItems[2].Text; } LoadList(m_lastSearchText); if (langName == string.Empty) { return; } // Restore the item that was selected before the sort. foreach (ListViewItem lvi in lvFindResult.Items) { if (lvi.Text == langName && lvi.SubItems[1].Text == country && lvi.SubItems[2].Text == ethnoCode) { lvFindResult.EnsureVisible(lvi.Index); lvi.Selected = true; break; } } }
/// ------------------------------------------------------------------------------------ /// <summary> /// When we get here, it means there was a long enough pause while typing in the search /// for text box that a search should be kicked off. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// ------------------------------------------------------------------------------------ protected void btnFind_Click(object sender, System.EventArgs e) { string searchFor = txtFindPattern.Text.Trim(); // Don't bother with the DB search if the search text is the same as the // previous text or if it's empty. if (m_lastSearchText != searchFor && searchFor != string.Empty) { m_currentSortBy = SortNamesBy.kLangName; // order by Name, Country. m_lastSearchText = searchFor; if (cboLookup.SelectedIndex == 0 && LanguageName == string.Empty) { LanguageName = searchFor; } LoadList(searchFor); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// When we get here, it means there was a long enough pause while typing in the search /// for text box that a search should be kicked off. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// ------------------------------------------------------------------------------------ protected void btnFind_Click(object sender, System.EventArgs e) { string searchFor = txtFindPattern.Text.Trim(); // Don't bother with the DB search if the search text is the same as the // previous text or if it's empty. if (m_lastSearchText != searchFor && searchFor != string.Empty) { m_currentSortBy = SortNamesBy.kLangName; // order by Name, Country. m_lastSearchText = searchFor; if(cboLookup.SelectedIndex == 0 && LanguageName == string.Empty) LanguageName = searchFor; LoadList(searchFor); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// ------------------------------------------------------------------------------------ private void lvFindResult_ColumnClick(object sender, ColumnClickEventArgs e) { if (lvFindResult.Items.Count == 0) return; // Figure out what the new sort order should be based on the column clicked on. SortNamesBy newSortBy = SortNamesBy.kLangName; switch (e.Column) { case 0: newSortBy = SortNamesBy.kLangName; break; case 1: newSortBy = SortNamesBy.kCountryName; break; case 2: newSortBy = SortNamesBy.kEthnoCode; break; } // Don't bother reloading the data if the sort order didn't change. if (m_currentSortBy == newSortBy) return; m_currentSortBy = newSortBy; // Save the currently selected item. string langName = string.Empty; string country = string.Empty; string ethnoCode = string.Empty; if (lvFindResult.SelectedItems.Count > 0) { langName = lvFindResult.SelectedItems[0].Text; country = lvFindResult.SelectedItems[0].SubItems[1].Text; ethnoCode = lvFindResult.SelectedItems[0].SubItems[2].Text; } LoadList(m_lastSearchText); if (langName == string.Empty) return; // Restore the item that was selected before the sort. foreach (ListViewItem lvi in lvFindResult.Items) { if (lvi.Text == langName && lvi.SubItems[1].Text == country && lvi.SubItems[2].Text == ethnoCode) { lvFindResult.EnsureVisible(lvi.Index); lvi.Selected = true; break; } } }