Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 246
  • Last Modified:

How to have different colored items in a listbox

I know this is a tough question but how can I have two different colored items in a list box.  I have two strings in all lists; either complete or imcomplete.  If the item in the listbox is "complete" then I want the backcolor of that item to be green.  If the item in the listbox is "incomplete" then I want the backcolor of that item to be red. I'm trying to emulate how Trancender does on their practice exam software. BTW, I am using the listbox for VB6 SP5.

0
Gmoney
Asked:
Gmoney
1 Solution
 
JohnMcCannCommented:
Check this out

http://www.vbaccelerator.com/codelib/odcbolst/article.htm

This example may need a little configuring as it uses VBAcellarators subclassing and timer control.  As well as another interface OleGuids.tlb.  Don't be put off by this control.  Play with it as it will do what you are asking.  As you try to implement your own I would ignore the OleGuids.tlb at first and the sunbclassing control is easy to implement.



0
 
JohnMcCannCommented:
Oh and is also freeware
0
 
GmoneyAuthor Commented:
Sorry John I was looking for help with the ListBox control that comes with VB6.
0
Technology Partners: 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!

 
GmoneyAuthor Commented:
Sorry John I was looking for help with the ListBox control that comes with VB6.
0
 
JohnMcCannCommented:
That is the only way I know to do it.

The VB6 ListBox is scaled down version of the ListBox Window class.

The code above enables you to do more with the listbox than is possible through VB.
0
 
PlanetCppCommented:
0
 
clavrgCommented:
AFAIK VB listbox does not allow to change background for given list item. Is it critical to use listbox? Why don't you just use something else or switch to different appearance, e.g. two textboxes, grid, or smth. else.

You can try to create your own control (you can even expand existing listbox), but, IMHO, it is time-consuming to do so.

Conclusion:
  standard component you wish to use does not provide features you desire. So to accomplish whatever you want you can:
  - switch to different component (your own one?)
  - extand existing one


Take a picture box, create dynamically textboxes within it, add scroll bar and track its position. Compose it into control and you will be able to change background by changing bckg of separate textboxes within picture box. It should not take long to do that.

BR,
Roman
0
 
ElizeCommented:
You could try the new titan textbox. If you take a look at the properties it has various options for changing the colour of text and backgrounds. I think that you can also have columns within the textbox. You have to pay for the control but they may have a demo version. www.visionomics.net
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now