Solved

Select listview item programatically

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

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 …
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

776 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