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

Answers


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


Need Your Help

Innosetup - reference a file from before the installation starts

installer inno-setup helpfile context-sensitive-help

This is sort of a continuation of this question. I have a file that I want to include with my installation package (a .CHM help file) that I need to access during installation from code. It doesn't

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.