ListView row colour

Andy666

Member
Joined
Aug 17, 2005
Messages
8
Programming Experience
Beginner
I am using a ListView set to detail view to display a range of data. It would be much better if i could change the colour of certain rows to make them stand out a bit more. The reason being, some of the rows are more like headers for the rows below. If i could change the back colour, font colour or even just making the font bold would be better than what i have got. Does anyone know if this is possible?? Note: i only want to do this for some rows not all of them.
 
VB.NET:
 Dim lvitem As ListViewItem 
 
 
lvitem = ListView1.Items.Add("Default font")
 
lvitem.SubItems.Add("Default fontstyle")
 
 
lvitem = ListView1.Items.Add("Times New Roman")
 
lvitem.SubItems.Add("Bold FontStyle")
 
ListView1.Items(1).Font = New Font("Times New Roman", 10, FontStyle.Bold)
 
 
lvitem = ListView1.Items.Add("Arial")
 
lvitem.SubItems.Add("Italic FontStyle")
 
ListView1.Items(2).Font = New Font("Arial", 10, FontStyle.Italic)
 
 
lvitem = ListView1.Items.Add("Tahoma")
 
lvitem.SubItems.Add("Red Color text")
 
ListView1.Items(3).Font = New Font("Tahoma", 10, FontStyle.Italic)
 
ListView1.Items(3).ForeColor = Color.Red
 
 
lvitem = ListView1.Items.Add("Verdana")
 
lvitem.SubItems.Add("Blue BackColor")
 
ListView1.Items(4).Font = New Font("Verdana", 10, FontStyle.Bold)
 
ListView1.Items(4).ForeColor = Color.Silver
 
ListView1.Items(4).BackColor = Color.SeaGreen

note that you can also control each cell of listview i.e.
lvItem.SubItems(0).Font = New Font("Arial", 10, FontStyle.Bold)


I guess you will find some sense otherwise let me know and i'll provide you more explanation ... Regards ;)
 
Good to hear ... happy coding
palec.gif
 
Back
Top