Solved

VB.NET ListView - Select first item

Posted on 2002-06-27
2
1,389 Views
Last Modified: 2007-12-19
Anybody knows how to select the first top item displayed on a listview once sorted by alpha without having to loop through all the items and compare again?

note: ListView1.Items(0).Selected won't work here...
0
Comment
Question by:ourman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 4

Accepted Solution

by:
DarthPedro earned 25 total points
ID: 7114584
Why won't that line of code work?  I just tried it, and it seemed to do the job.  I started by adding a list of items into the ListView.  Then sorting them when the column header was clicked, like this:

    private void listView1_ColumnClick(object sender, System.Windows.Forms.ColumnClickEventArgs e)
    {
        listView1.Sorting = SortOrder.Ascending;
        listView1.Items[0].Selected = true;
    }

The first item in the sorted list was selected...
0
 

Author Comment

by:ourman
ID: 7116347
A typical idiot's question: I was selecting the item before sorting the listview.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question