Selecting an item in a ListView control ( winforms ) while not having the focus

Posted by rahulchandran on Stack Overflow See other posts from Stack Overflow or by rahulchandran
Published on 2010-03-27T23:55:45Z Indexed on 2010/03/28 0:03 UTC
Read the original article Hit count: 658

Filed under:
|

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

© Stack Overflow or respective owner

Related posts about winforms

Related posts about listview