Solved

Listview Question

Posted on 2002-04-05
4
288 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks escheider.  Glad I could help.
RichW
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

762 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

6 Experts available now in Live!

Get 1:1 Help Now