Wrox Programmer Forums
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old March 9th, 2004, 06:19 AM
Authorized User
Join Date: Jul 2003
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default listview control

Does the Listview control have a property that tells you which item was selected?

For reasons too lengthy to go into, I want to make a note of the item a user has selected in a Listview control, clear that Listview control, repopulate it and highlight the item originally selected.

I've seen several properties which seem to do what I want but they all require you to specify an index number. Since I don't know what item a user may click on, I don't know what that index number will be.

Any pointers appreciated.


Old March 9th, 2004, 08:29 AM
Authorized User
Join Date: Aug 2003
Posts: 44
Thanks: 0
Thanked 0 Times in 0 Posts

How about

For i = 0 To lstList.ListCount - 1

If lstList.Selected(i) = True Then

    'your actions here

end if


If you just have a listview where you can only select one item you can also use:


This returns the index of the selected item.



Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with ListView Control in C# jiggsroger C# 2005 7 April 7th, 2008 04:25 AM
About Listview control yuetqu BOOK: Beginning VB.NET 2nd Edition/Beginning VB.NET 2003 1 August 15th, 2006 04:56 AM
Refreshing a ListView control osemollie Pro VB 6 1 July 26th, 2006 10:00 AM
ListView Control JelfMaria VB How-To 4 May 5th, 2005 12:39 AM
ListView Control jlr27613 C++ Programming 1 September 14th, 2004 12:58 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.