Is it possible to adjust colors of rows within a listbox? (1 Viewer)

mamradzelvy

Member
Local time
Today, 18:51
Joined
Apr 14, 2020
Messages
145
Hi,
the title says it all basically. I'm looking for a way to set background color of individual rows within a listbox, is that achievable?

I saw some posts regarding using a ListView instead of ListBox, but those were rather old so i figured that info might be outdated (?)
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 12:51
Joined
May 21, 2018
Messages
8,525
There is an ActiveX control in the MSComCtl library called a listview that does this. Unless you are a good in vba I would bag it. The object is poorly documented and it is kind of a PIA to work with.

listview.jpg
 

isladogs

MVP / VIP
Local time
Today, 17:51
Joined
Jan 14, 2017
Messages
18,209
Just to add, I have a feeling a listview can't be used in 64-bit Access as its part of the old Common Controls libraru
 

mamradzelvy

Member
Local time
Today, 18:51
Joined
Apr 14, 2020
Messages
145
Its partly achievable with a listbox. See http://www.mendipdatasystems.co.uk/add-query-colour/4594424152

However colour formatting is limited in ways that probably won't satisfy your needs
Consider using a subform with conditional formatting instead. Subforms can be made to look like listboxes

Ah that's nice, but i can not imagine this working unless i would migrate data from table to table to achieve the color i want as the color is defined in the actual tables' column format property, right?
 

mamradzelvy

Member
Local time
Today, 18:51
Joined
Apr 14, 2020
Messages
145
There is an ActiveX control in the MSComCtl library called a listview that does this. Unless you are a good in vba I would bag it. The object is poorly documented and it is kind of a PIA to work with.

View attachment 81577
I'm so new to all of this, i don't even know ActiveX yet or how to work with libraries. But i appreciate your resourcefulness my good man.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 12:51
Joined
May 21, 2018
Messages
8,525
I'm so new to all of this, i don't even know ActiveX yet or how to work with libraries
In design view below the standard controls (textbox combobox etc) you can pick other activex controls. They are not as easy to use as the native controls.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 12:51
Joined
May 21, 2018
Messages
8,525
Here is my favorite ActiveX control the Treeview. This comes with the listview in the same library. To use them you just need to set a reference to the library in the references window.
 

mamradzelvy

Member
Local time
Today, 18:51
Joined
Apr 14, 2020
Messages
145
Here is my favorite ActiveX control the Treeview. This comes with the listview in the same library. To use them you just need to set a reference to the library in the references window.

That's some advanced stuff right here!
I'll get there, all in due time-or rather, when i'll have use for this, i'll remember that you gave me a good preview of what's possible, thank you once more!
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 12:51
Joined
May 21, 2018
Messages
8,525
Making a subform to act and look like a listbox as @isladogs said is what you should pursue if you really want color. That is not too hard.

I have a feeling a listview can't be used in 64-bit Access as its part of the old Common Controls library
That image is off of my upgraded computer running office 2019 and win 10 64bit.
 

isladogs

MVP / VIP
Local time
Today, 17:51
Joined
Jan 14, 2017
Messages
18,209
That image is off of my upgraded computer running office 2019 and win 10 64bit.

I stand corrected. I was thinking of the old MS Common dialog control reference library
 

isladogs

MVP / VIP
Local time
Today, 17:51
Joined
Jan 14, 2017
Messages
18,209
Ah that's nice, but i can not imagine this working unless i would migrate data from table to table to achieve the color i want as the color is defined in the actual tables' column format property, right?
Sorry forgot to reply to this. That's correct. I said it was of limited use. Subform formatting is the best approach
 

CJ_London

Super Moderator
Staff member
Local time
Today, 17:51
Joined
Feb 19, 2013
Messages
16,608
as the color is defined in the actual tables' column format property, right?
Nope - unless it's a new feature in 365 versions?

the table format property allows a limited range of fore colours - but only on the type of values (is null or not for text, positive, negative, zero or null for numbers) - and both listboxes and comboboxes will display all values as text and ignore any field format properties - numbers are left justified for example. If you need the functionality, better to build your own - use a subform
 

isladogs

MVP / VIP
Local time
Today, 17:51
Joined
Jan 14, 2017
Messages
18,209
HI CJ
Being as we seem to be partly contradicting each other, the example I gave in post #2 does indeed use the table field formast property in exactly the way you stated. For text fields that is displayed in the listbox columns but not for number or date fields.
Here's a screenshot from that example app

Capture.PNG

My article that I referred to in post #2 includes a lengthy quote from yourself explaining what is possible.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 17:51
Joined
Feb 19, 2013
Messages
16,608
perhaps we are at cross purposes - my emphasis was on 'but only on the type of values'. So from a row perspective the best you could do is ensure to datatypes were all text and either all null or all have a value - and then the point is they would all be one colour (or blank in the case of null) - since we were 12 posts in I thought I would emphasise the point.

In your example I guess you could format numbers as text in the rowsource and apply text formatting
 

Users who are viewing this thread

Top Bottom