Solved

Listview Question

Posted on 2002-04-05
4
301 Views
Last Modified: 2012-05-04
Hello Experts:

I have a listview that displays invoices.  I want to change the color of the font in the row based on the status of the invoice.

If the invoice has been paid, it should be red
If the invoice has been paid late, it should be yellow
If the invoice is current, it should be black.

I know you use the following syntax to change the forecolor of the item:

InvoiceList.ListItems(Counter).ForeColor = vbRed
lv.ListSubItems(1).ForeColor = vbRed
lv.ListSubItems(2).ForeColor = vbRed

But I don't want to do this for every different color, so Id like to put the color to be displayed in a variable and do the following:

InvoiceList.ListItems(Counter).ForeColor = ColorSelect
lv.ListSubItems(1).ForeColor = ColorSelect
lv.ListSubItems(2).ForeColor = ColorSelect

And use a select statement to determine the status of the invoice.

Question is, what variable type would I define ColorSelect as so it can hold values like vbred, vbblue, etc.?

VB6

0
Comment
Question by:escheider
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 4

Accepted Solution

by:
RichW earned 10 total points
ID: 6921225
You might be better off using the QBColor(color) method.

0 Black 8 Gray
1 Blue 9 Light Blue
2 Green 10 Light Green
3 Cyan 11 Light Cyan
4 Red 12 Light Red
5 Magenta 13 Light Magenta
6 Yellow 14 Light Yellow
7 White 15 Bright White

To change a color property to red you could try:

Dim lngColor as Long
lngColor = 4
Listview.BackColor = QBColor(lngColor)

0
 
LVL 5

Expert Comment

by:rkot2000
ID: 6921252
Dim ColorSet as long

or

dim ColorSet(2) as long
ColorSet(0)=vbRed
ColorSet(1)=vbGreen
ColorSet(2)=vbBlack
0
 
LVL 4

Author Comment

by:escheider
ID: 6921277
Thanks Rich...I love quick and easy answers..

I appreciate everyone's input, thanks for taking time out of your busy day to help...
0
 
LVL 4

Expert Comment

by:RichW
ID: 6921925
Thanks escheider.  Glad I could help.
RichW
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question