Select ListView Item Programmatically

Submitted on: 1/1/2015 6:42:00 PM
By: Jason Heine (from psc cd)  
Level: Beginner
User Rating: By 43 Users
Compatibility: VB.NET
Views: 1876
     This simple code will allow you to programmatically select an item in a listview. Hope this helps.


How to select a ListView Item Programmatically.


This is a simple process, but most people forget a little step in doing this.

Step 1:

Create a ListView Item and name it to whatever you wish. I will use lv for simplicity.

Step 2:

Create a Button Item

Step 3:

Double Click the Button to start typeing code.


Step 4:

Enter the following code:

Private Sub Button1_Click(......) Handles Button1.Click

      lv.Items(0).Selected = True

      lv.Select() 'This is what most people forget. If you don't put this in here, it will never select the item in the list view.

End Sub

And that is it! Really Really simple, but very useful.


Step 5:

If you find this code useful. Vote for me.

Other 1 submission(s) by this author


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this article (in the Beginner category)?
(The article with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)

Other User Comments

 There are no comments on this submission.

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular article, please click here instead.)

To post feedback, first please login.