Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Pro VB 6
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Pro VB 6 For advanced Visual Basic coders working in version 6 (not .NET). Beginning-level questions will be redirected to other forums, including Beginning VB 6.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old October 20th, 2003, 06:08 AM
Authorized User
 
Join Date: Jun 2003
Location: Lisbon, , Portugal.
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
Default Change color of items in a ListView

Hello,

I need to have items in a listview with different colors. Does anybody knows how to do it, or if it is possible to do?

Thanks in advance,

Elisa Resina
__________________
Elisa Resina
Reply With Quote
  #2 (permalink)  
Old October 20th, 2003, 03:29 PM
Registered User
 
Join Date: Jun 2003
Location: , , .
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

eresina:

Simply use the ForeColor property for each ListView item whose color you wish to change.
Reply With Quote
  #3 (permalink)  
Old June 21st, 2006, 06:50 PM
Friend of Wrox
 
Join Date: Mar 2005
Location: , , .
Posts: 264
Thanks: 0
Thanked 0 Times in 0 Posts
Default

jim roger can u show me an example of making each item of listview diffrent color ?Thanks

Reply With Quote
  #4 (permalink)  
Old April 10th, 2007, 07:14 PM
Registered User
 
Join Date: Apr 2007
Location: , , Canada.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

AFAIK you can't do that. If you must, use a MSFlexGrid control. That control is completely different from a listview, but does allow you to change a ton of properties on a cell-by-cell basis.

Reply With Quote
  #5 (permalink)  
Old April 11th, 2007, 09:47 AM
Friend of Wrox
 
Join Date: May 2006
Location: San Diego, CA, USA.
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by doug65536
 AFAIK you can't do that. If you must, use a MSFlexGrid control. That control is completely different from a listview, but does allow you to change a ton of properties on a cell-by-cell basis.


doug65536: Answering a post that is over 3 years old is probably not all that useful.
But just in case someone is actually interested, the correct answer is that you CAN use various foreground colors of items in a listview.

Each listview item has a forecolor property, which can be set to an RGB setting, and each subitem also has a forecolor property which can also be set to an RGB color..

Here is a simple example:

Code:
Private Sub Command1_Click()
    Dim item As ListItem
    ListView1.ListItems.Clear
    Set item = ListView1.ListItems.Add(Text:="Bill")
    item.ForeColor = vbGreen
    item.SubItems(1) = "Gates"
    item.ListSubItems(1).ForeColor = vbRed
End Sub
This example assumes you have a listview named ListView1 that has at least 2 columns and has its view property set to lvwReport. And, of course, that you have a command button named Command1.


Woody Z
http://www.learntoprogramnow.com
How to use a forum to help solve problems
Reply With Quote
  #6 (permalink)  
Old June 3rd, 2016, 08:26 AM
Registered User
Points: 6, Level: 1
Points: 6, Level: 1 Points: 6, Level: 1 Points: 6, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2016
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

I just wanted to say that I came to this post wile searching about coloring background of listitems elements in a listview and I found the suggestion to use the MSflexgrid useful.

This is almost 10 years since the last comment but this thread is still useful, it is the 8th result of a search for "listview listitem backcolor" in google.
Reply With Quote
  #7 (permalink)  
Old September 15th, 2016, 05:09 PM
Registered User
Points: 24, Level: 1
Points: 24, Level: 1 Points: 24, Level: 1 Points: 24, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2011
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi,

just chiming in that this post was useful to me too. We are using VBA at one of the world's top companies. Still relevant

thx
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to update table with listview items Singh591 Pro VB.NET 2002/2003 0 December 30th, 2006 10:13 PM
Listview doesnt change after items are selected. hexOffender VB.NET 2002/2003 Basics 0 December 13th, 2006 11:28 AM
How to change color of selected external listview method VB How-To 8 October 20th, 2006 07:01 PM
Writting listview items to xml document chandler7272 C# 0 June 12th, 2006 06:01 AM
Listview Cell Color leontun Pro VB 6 2 December 15th, 2004 03:14 PM



All times are GMT -4. The time now is 01:11 PM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.