Click here to Skip to main content
15,881,172 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I set my ListView properties like this
ListView1.View = View.List
ListView1.FullRowSelect = True
ListView1.GridLines = True

But still when I select any item in ListView, the full row is not highlighted. It only highlight the icon with it's text. Is there any way I can highlight the whole row when selected? I already do some research but all I found are mention to set the FullRowSelected to True but that seems not working for me.
Posted
Updated 3-Oct-22 10:13am
Comments
Kenneth Haugland 12-Nov-15 2:14am    
This is WinForms I assume?
dell-gl62m 12-Nov-15 2:15am    
Yes. It's a WinForms. Do you have any idea?
Kenneth Haugland 12-Nov-15 2:16am    
Nope, but if you switch to WPF I can help you :laugh:
dell-gl62m 12-Nov-15 2:19am    
:D nvm
Naveen.Sanagasetti 12-Nov-15 2:42am    
Refer below link this might be helpful to you, http://www.codeproject.com/Articles/1397/Selection-Highlighting-of-an-Entire-Row

Try below, just put in an event to your list view and get the index selected and replaced the zero below.

ListView1.Items[0].Selected = True
 
Share this answer
 
Comments
dell-gl62m 12-Nov-15 2:33am    
Thank you for your reply but I already did that and it isn't working too :(
I even set the ListView1.Focus() but still the same result.
seravan 12-Nov-15 2:51am    
Should this really be a "ListView1.View = View.List" or are you looking for Details?

I tried below on my formload and it was able to highlight.

ListView1.View = View.List
ListView1.FullRowSelect = True
ListView1.GridLines = True

For index As Integer = 0 To 3
ListView1.Items.Add("Number" & index.ToString()).SubItems.Add("text")
Next

ListView1.Items(1).Selected = True
dell-gl62m 12-Nov-15 3:09am    
Here is my coding that I currently use.

ListView1.View = View.List
ImageList1.ImageSize = New Size(32, 45)
ImageList1.Images.Clear()
ListView1.SmallImageList = ImageList1
ListView1.Items.Clear()
ListView1.FullRowSelect = True
ListView1.GridLines = True

For i = 0 To 9
Title = myList(0, i, 0) 'Path of image title inside my array
Img = myList(0, i, 2) 'Path of image url inside my array
If Title <> "" Then
ImageList1.Images.Add("imgKey" & i, New Icon(Img))
ListView1.Items.Add(Title, "imgKey" & i).Selected = True
ListView1.Focus()
End If
Next

Or maybe I do it wrong?
dell-gl62m 12-Nov-15 3:32am    
Never mind, it solved already. I just add column in my ListView and set the FullRowSelect to True and view as Details. By the way, thank you so much for your response. I appreciate it so much :)
if (this.listViewProjects.Items.Count > 0)
{
this.listViewProjects.Items[0].Selected = true;
this.listViewProjects.Items[0].Focused = true;
this.listViewProjects.Focus();
this.listViewProjects.FocusedItem = this.listViewProjects.Items[0];
}
 
Share this answer
 
Comments
Jonou 4-Sep-20 20:26pm    
I know the post is old, but this actually works if you only need the 1st item highlighted.

But what if I needed to highlight all the items that have a check mark?
Any suggestions?
I use this in DoDataExchange
m_ListCtrl.SetExtendedStyle(LVS_EX_FULLROWSELECT);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900