Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Different colors for different rows in list box

Status
Not open for further replies.

bengy2

Programmer
May 11, 2004
3
SK
OS: Windows XP
Access: MS Access 2002

I have database (Tasks):
Name (name of task)
.
.
.
Status (progress, completed ...)

I wan to display it in list box on form.
My question is if there is any possibility to have different background color for task with different status (for example green for completed, red for overdue ...) ?

Bengy2
 
Not in a list box, but if you create a subform you can probably do something with conditional formatting.

Randy
 
I suppose that you could try subclassing the listbox control and changing its style to OWNERDRAW. This would increase substantially your power (and the work required to do so) over the listbox and its display attributes. If you don't know what I just said, then I wouldn't recommend taking this approach.

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Until I read CajunCenturion's post, I thought you would have to write an ActiveX Control in order to do what you are asking. I like the sound of Cajun's Post though, and am interested in going to try out "OWNERDRAW" and subclassing. In my understanding, the problem with the ListBox, is that when you alter a property of the listbox, you are altering the properties for all of the items in the ListBox. (With at least one exception being the text entry itself, which of course have to be able to be unique.)
 
I probably should not have mentioned it because to properly subclass the listbox and handle its drawing requires the use of a dozen APIs and lots of details that you need to be concerned about.

It would probably be easier to write the ActiveX control, or my preference would be to use something like a FlexGrid and make it behave like a listbox. A while back, I used a flexgrid, a command button, and a textbox to simulate a multi-colored, multi-column combo box. That was easier (and safer) in many ways than subclassing.

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
A "poor man's" way would be to include a second field in the list box listing the status of the task. You could even sort the list box by status.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top