?
Solved

How to have different colored items in a listbox

Posted on 2003-03-01
8
Medium Priority
?
242 Views
Last Modified: 2012-05-04
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
Comment
Question by:Gmoney
[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
8 Comments
 
LVL 5

Expert Comment

by:JohnMcCann
ID: 8050116
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
 
LVL 5

Expert Comment

by:JohnMcCann
ID: 8050120
Oh and is also freeware
0
 

Author Comment

by:Gmoney
ID: 8050273
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!

 

Author Comment

by:Gmoney
ID: 8050336
Sorry John I was looking for help with the ListBox control that comes with VB6.
0
 
LVL 5

Expert Comment

by:JohnMcCann
ID: 8050427
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
 
LVL 6

Expert Comment

by:PlanetCpp
ID: 8050516
0
 

Accepted Solution

by:
clavrg earned 800 total points
ID: 8052936
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
 

Expert Comment

by:Elize
ID: 8055488
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

Industry Leaders: 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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…
Suggested Courses
Course of the Month9 days, 3 hours left to enroll

764 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