Selecting an item in a ListView control ( winforms ) while not having the focus
- by rahulchandran
I am trying to mimic the functionality of the address book in Outlook
So basically a user starts typing in some text in an edit control and a matching ListView Item is selected
private void txtSearchText_TextChanged(object sender, EventArgs e)
{
ListViewItem lvi =
this.listViewContacts.FindItemWithText(this.txtSearchText.Text,true, 0);
if (lvi != null)
{
listViewContacts.Items[lvi.Index].Selected = true;
listViewContacts.Select();
}
}
The problem with this is once the listview item gets selected the user cant keep typing into the text Box. Basically I want a way to highlight an item in the listview while still keeping the focus on the edit control
This is WINFORMS 2.0