Solved

Select listview item programatically

Posted on 2014-04-28
2
503 Views
Last Modified: 2014-04-29
Experts, I populate a listview from a database. I have a form for the user to add new items or edit an item. When the user adds a new item I repopulate the listview. When this happens i would like to have the item that was just entered selected for the user.
 
After the INSERT query i retrieve the ID of the record that was just inserted. When the items are added to the listview initially i use the name property of the list item and set it to the ID of the record.

lstItem.name = reader.item("ID")

I would never know the index of the item that was just entered, only the ID of the record.
With the setup i have is there a way to select the item i just entered.
0
Comment
Question by:Basicfarmer
2 Comments
 
LVL 25

Accepted Solution

by:
Luis Pérez earned 500 total points
ID: 40029000
Once you've populated your ListView, you can do this:

Me.ListView1.Items(name).Selected = True

For example:

Me.ListView1.Items(reader.Item("ID")).Selected = True

Hope that helps.
0
 

Author Closing Comment

by:Basicfarmer
ID: 40029610
Thanks for the great response...
0

Featured Post

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

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…
When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
This video teaches viewers about errors in exception handling.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

809 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