Listbox Items

Making different items in a listbox different colors

Page 1 of 1

2 Replies - 8432 Views - Last Post: 23 March 2007 - 04:43 PM Rate Topic: -----

#1 danfwald  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 25-July 06

Listbox Items

Posted 06 March 2007 - 11:09 AM

Is it possible to make different items in a listbox different colors depending on certain program variables? The listbox.forecolor property makes all items in the collection the same color. I want to do the following:

if x > 0 then listbox.forecolor = color1 : listbox.items.add(x.tostring)
if x < 0 then listbox.forecolor = color2 : listbox.items.add(x.tostring)
Is This A Good Question/Topic? 0
  • +

Replies To: Listbox Items

#2 KeyWiz  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 8
  • View blog
  • Posts: 438
  • Joined: 26-October 06

Re: Listbox Items

Posted 07 March 2007 - 11:49 AM

You can create a custom CLASS which inherits the LISTBOX Class
then you provide OverRides for each line, to change the text color.
Then Call the new Class - whatever you name it (ColorListBox) and create an instance of your new class object.
You will then have to define the new Line Color properties based on your new Class
Was This Post Helpful? 0
  • +
  • -

#3 danfwald  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 25-July 06

Re: Listbox Items

Posted 23 March 2007 - 04:43 PM

View PostKeyWiz, on 7 Mar, 2007 - 11:49 AM, said:

You can create a custom CLASS which inherits the LISTBOX Class
then you provide OverRides for each line, to change the text color.
Then Call the new Class - whatever you name it (ColorListBox) and create an instance of your new class object.
You will then have to define the new Line Color properties based on your new Class



I have been playing around with your suggestion, but getting nowhere. Would you please write a few lines of code showing the overrides in the new class that inherits the listbox class.

Thanks
dan
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1