Solved

VB.NET ListView - Select first item

Posted on 2002-06-27
2
1,258 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
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now