Solved

Select listview item programatically

Posted on 2014-04-28
2
493 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Having just graduated from college and entered the workforce, I don’t find myself always using the tools and programs I grew accustomed to over the past four years. However, there is one program I continually find myself reverting back to…R.   So …
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

757 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

16 Experts available now in Live!

Get 1:1 Help Now