Solved

Listview Question

Posted on 2002-04-05
4
295 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
DIR issue 7 51
Access 2003, my txt file export is running backwards 4 47
How to create a duplicate finder Application 9 115
Excel - Save a copy of work book 13 83
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

920 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now