Change the color of a cell in a listview column
Solved
mylord666
Posted messages
162
Status
Member
-
mylord666 Posted messages 162 Status Member -
mylord666 Posted messages 162 Status Member -
Good evening
who can tell me why I can read the cell but cannot change the color
here is my code
listview1.items(1).subitems(5).backcolor=color orange
msgbox(listview1.items(1).subitems(5).text)
thank you for your help
who can tell me why I can read the cell but cannot change the color
here is my code
listview1.items(1).subitems(5).backcolor=color orange
msgbox(listview1.items(1).subitems(5).text)
thank you for your help
2 answers
-
Hello,
while looking at this site:
https://plasserre.developpez.com/cours/vb-net/?page=ui-winforms3#LVIII-H-4
you find this:
'Set the background of a cell to red ListView1.Items(2).UseItemStyleForSubItems= False ListView1.Items(2).SubItem(3).BackColor= Colors.Red 'Set a row to green ListView1.Items(2).BackColor= Colors.Lime
--
@+ The Woodpecker -
Indeed, it's a mistake on the website:
there's a missing "s" in SubItem
there's an extra "s" in Colors
'Set the background of a cell to red ListView1.Items(0).UseItemStyleForSubItems = False ListView1.Items(0).SubItems(0).BackColor = Color.Red 'Set a row to green ListView1.Items(0).BackColor = Color.Lime
If you put Option Strict On at the top of your code, the errors will show up, and you just need to right-click to fix them.
Another tip is that if you put a dot after Color, a context menu will appear with all the colors. This applies to everything:
ListView1.Items(0).
for example will display SubItems
Happy coding
--
@+ Le Pivert