Click here to Skip to main content
15,667,010 members
Please Sign up or sign in to vote.
1.44/5 (2 votes)
See more:
I have an Installshield project using installscript. In that project I have a listview with several columns and multiple rows.

What I need is the code to be able to change the row(s) to different colors.

I found code to change the whole background of the listview but I need the ability to change the individual rows to different colors. e.g., 1st row red, 2nd row blue, 3rd row green, 4th row red and etc.

Thank you

What I have tried:

Using SendMessage but there's in no obvious way to use things such as NM_CUSTOMDRAW and etc.
Updated 19-Jan-23 13:31pm
Dave Kreskowiak 14-Jan-23 18:43pm    
Why would you want to do this in an installer?

1 solution

I agree with Dave - why? Whilst a good idea in a dev's mind is not always a good idea to stray from the industry standard as users are easily confused. If you do, it will need a context that users can easily understand.

However, you have asked for a how, so I did a quick google search[^] and found this solution: Custom ListView in Winforms? - StackOverflow[^] which points to the following:
* ListView.DrawItem Event (System.Windows.Forms) | Microsoft Learn[^]
* ListView.DrawColumnHeader Event (System.Windows.Forms) | Microsoft Learn[^]
Both links provide sample code for you.
Share this answer
Member 735811 19-Jan-23 19:51pm    
I appreciate your help and I've seen these solutions but I don't know how to port them to InstallShield. In InstallShield I can't find a way to trap or get a message for a 'Redraw' or 'Paint' messages.

As for why, I don't see why people, answer a question with a question. This is a customer's request. And it is valid and I could go on and on explaining, but asking why someone what's to do something, with a code question, does not help and in fact wastes everyone's time. I've seen this time and time again in almost all coding forums. Usually the people asking why are the ones that don't know how to answer the question. So in short if the question is above your pay grade find something else to do with your time.
Dave Kreskowiak 19-Jan-23 20:19pm    
Considering I've been repacking software installers and dealing with vendors who can't write an installer to save their lives, yes, I do know how to answer it.

The problem is, typically, an installer is only ever run twice. Once when the app is installed and once when it's uninstalled. Why are you putting so much effort into something that just increases the complexity of the installer for no real benefit?

No, the "customer requested it" is not a valid answer. Customers typically do not have a clue what they really want and just throw "requirements" on that mean nothing to the actual function of the app. It's your job to filter that kind of stuff out and not just blindly follow the "customer is always right" philosophy.

Without knowing the details of why they want this, you're wasting your time and the customers money implementing it. Do you think it's a good idea to waste customer money?
Graeme_Grant 19-Jan-23 20:46pm    
5'd ... I just gave him pointers that if he was to go down that road, how to research it. That is his choice if he wants to do so.

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