masterchris_99
masterchris_99

Reputation: 2733

Select programmatically a row of a Listview

I don't get it to work to select a row of a listview at the beginning of my program.

        if (listView1.Items.Count > 0)
        {
            listView1.Items[0].Selected = true;
            listView1.Items[0].Focused = true;
        }

After running this snippet the first item is selected and focused.

listView1.Items[0].Selected
true 
listView1.Items[0].Focused 
true

after clicking manually an item in the listview I can walk thru this list with

listView1.Items[newPosition].Selected = true;

regards

Upvotes: 1

Views: 11634

Answers (1)

Bolu
Bolu

Reputation: 8786

set listView1.HideSelection=false and listView1.Focus()

Upvotes: 3

Related Questions