Solved

VB.NET ListView - Select first item

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB.NET (2008) - Refactoring Question 2 21
Regular expression help 2 25
VB.NET 2008 Publish Error 2 27
Can't disable touch pad on Windows 10 computer 16 33
IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.

777 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