Solved

Listview Question

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

Independent Software Vendors: 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

Suggested Solutions

Title # Comments Views Activity
fso.FolderExists("\\server\HiddenFolder$") 4 96
checkbox to hide entire section 10 75
add criteria to query in VB, Access 2003 2 47
VB6 Enviroment 3 33
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…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…

739 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