Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Highlight a listview record 1

Status
Not open for further replies.

AlanCh

MIS
Aug 21, 2001
19
CA
Hello,
Is there any way to highlight a listview record (row) if the index of the row is known? I have seen similar posts for selecting a row, but i haven't seen any code to "highlight" a row? Any help would be greatly appreciated.

Thanks.
 
ListView1.ListItems(Index).Selected=True
ListView1.SelectedItem.Ensurevisible

If I understand what you're wanting, this will work.
 
Thanks bjd4jc for your speedy response. What I am actually looking for is something that will physically highlight the desired row ... giving the same effect as if you were to click on the row in the listview.

I have tried your example code, but I believe the EnsureVisible method just makes sure the selected record is visible on screen so that you don't have to scroll up and down the listbox.

Let me know if you can think of anything.

Thanks.
 
I'm not sure if this is the best way but this is the way i've done it in the past

dim li as listitem
dim intIndex as long

For Each li In lvwJobsOnDrawing.ListItems
If li.Index = intIndex Then
Set lvwJobsOnDrawing.SelectedItem = li
End If
Next
 
oh!!

Also obviously you need to assign intindex to the value of the index that you are looking for as well before you do this.

Just thought i'd add that though as i've found i shouldn't assume that people know what i do.

Transcend
[gorgeous]
 
Also make sure the "HideSelection" property of the listview is not checked. Right click on the Listview and select properties to find this property. Note if you are in report mode then the other columns are not effected.
 
Thanks Trancend for your response. I actually had tried your code (and something similar before) but it didn't highlight the record. Although I know it was selected (from using msgbox to output one of the fields).

SemperFiDownUnda, your suggestion did the trick and was the only thing that was preventing me from seeing the selected record.

Thanks a million!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top