I have come across a piece of code that enables you to change the Backcolor property of any individual row, or rows, without the need for using subclassing. This is a big advantage for everybody, but especially those, like myself, with very limited knowledge of subclassing, but a better knowledge of the perils that it can bring.![]()
I have used this code and altered it a bit to make a fully commented example project to show how easy it is to use.
It requires just the addition of a Picturebox control to your form and thats it, nothing more complicated than that.
It uses the Line Method to fill in the colour in the specified places in the picturebox, i.e. the rows.
See Here for information about the Line method (MSDN)
You would then add a hidden column to the listview to store the value of the Checkbox, which would then be saved to, and loaded from your database when loading the other columns in your listview. Simple![]()
Limitations:
I have noticed that when you get to more that approx 200 records, the colouring or the rows starts to go outside of the lines for each row.
To try this, just change this line in the Form_Load event in the attached project:
The original author of this code is De ming Shang, who I give full credit to for such a simple, but effective alternative to subclassing.Code:'\\Load data into Listview For i = 0 To 200 <--Change to 1000
Screenshot of Listview with coloured rows.


Reply With Quote
