ListView & ListBox, Colors

Is it possible to have items added different colors?

Page 1 of 1

4 Replies - 2729 Views - Last Post: 11 April 2009 - 07:27 PM Rate Topic: -----

#1 jimdandy75  Icon User is offline

  • D.I.C Regular

Reputation: 37
  • View blog
  • Posts: 310
  • Joined: 30-June 08

ListView & ListBox, Colors

Post icon  Posted 11 April 2009 - 06:52 PM

I use buttons to populate my listview, and I was wondering if it's possible to have items different colors.
I've tried this several ways, and it always ends up changing all the items color in the listview. Here's
one of my attempts, but it changes all the items when I click the button to add a new one. Have a feeling
it might not even be possible to have different items different colors.

		ListView1.ForeColor = Color.DarkGreen


Thanks

Is This A Good Question/Topic? 0
  • +

Replies To: ListView & ListBox, Colors

#2 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 1998
  • View blog
  • Posts: 8,808
  • Joined: 29-May 08

Re: ListView & ListBox, Colors

Posted 11 April 2009 - 07:15 PM

Create a new ListViewItem item for each entry. You the can alter the properties of each item.
For Example
 Dim a As New System.Windows.Forms.ListViewItem("B")
  a.BackColor = Color.LightBlue
  a.ForeColor = Color.Red
  Me.ListView1.Items.Add("A")
  Me.ListView1.Items.Add(a)
  Me.ListView1.Items.Add("C")
  Me.ListView1.Items.Add("D")



Was This Post Helpful? 0
  • +
  • -

#3 June7  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 104
  • View blog
  • Posts: 904
  • Joined: 09-December 08

Re: ListView & ListBox, Colors

Posted 11 April 2009 - 07:20 PM

ListView is list box control? Then I think not possible to do what you want. As far as I have been able to tell, all text in controls is subject to properties of the control (font, colors, effects, etc). Unlike within an Excel cell where you can select parts of the content and apply formatting.

Edit: AdamSpeight2000 says it's possible. Sounds interesting.

This post has been edited by June7: 11 April 2009 - 07:22 PM

Was This Post Helpful? 0
  • +
  • -

#4 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 1998
  • View blog
  • Posts: 8,808
  • Joined: 29-May 08

Re: ListView & ListBox, Colors

Posted 11 April 2009 - 07:26 PM

ListView is a different control to a Listbox.
It's possible for the ListView to simulate a listbox.
Was This Post Helpful? 1
  • +
  • -

#5 jimdandy75  Icon User is offline

  • D.I.C Regular

Reputation: 37
  • View blog
  • Posts: 310
  • Joined: 30-June 08

Re: ListView & ListBox, Colors

Posted 11 April 2009 - 07:27 PM

Oh, it's possible I just just did it !!!
Thanks a ton Adam, u da man :^: :D
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1