Anyone have any idea if the background color of a treeview can be set via vba code? And, if so, can you point me to or provide an example.
![]() |
There are isolated problems with current patches, but they are well-known and documented on this site. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
-
Treeview Background Color (Access 2007)
Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Treeview Background Color (Access 2007)
- This topic has 4 replies, 2 voices, and was last updated 16 years, 5 months ago.
Viewing 0 reply threadsAuthorReplies-
WSHansV
AskWoody LoungerDecember 6, 2008 at 9:31 am #1136197The treeview control has no built-in support for this; you need to use Windows API functions.
Copy the code from the attached text file (source: VB Helper Tutorial: Background Color) into a new standard module, and use a line like the following in the On Load event of the form with the treeview control:
ChangeBackgroundColor Me.Treeview1.hWnd, vbRed
Replace Treeview1 with the name of the treeview control and vbRed with the color that you want to use. You can use a symbolic constant for a literal color such as vbRed, a system color such as vbInfoBackground, or an RGB value such as RGB(255, 0, 128).
Important: treeview nodes are *not* transparent, so you have to set the BackColor property of the nodes too.
-
WSmcowen
AskWoody LoungerDecember 8, 2008 at 1:22 pm #1136684Hans,
Thanks much. However, there must be one more consideration I’m overlooking. I have a three level tree and, between your code and setting the BackColor as I build each node level, the BackColor seems to work with the exception of the last items at each level. eg ( The last Level 1 node doesn’t have the color set in the narrow band/column under its + for each Level 2 item. Similarly, the last Level 2 node under each Level 1 node has the same effect, the color is not set under its + for each Level 3 item. And finally, the last Level 3 node under each Level 2 has the same no-color problem for each item.) My sequence for the Treeview is: set the treeview properties, create Level 1 node items with BackColor, create Level 2 nodes with BackColor, create Level 3 nodes with BackColor and finally set the Treeview BackColor with your code. Thinking it might be a timing issue, I’ve tried moving the ChangeBackgroundColor to before and aslo after the setting of its general properties … no difference.
Appreciate any insights you have,
Marty -
WSHansV
AskWoody LoungerDecember 8, 2008 at 5:59 pm #1136741Using Windows API functions is a “dirty” trick – the treeview control was not designed with a non-standard background color in mind, so it behaves unpredicatably if you set the background color anyway. I think you’ll have to choose between not setting the background color (which would be my preference) and living with the quirks if you do.
-
WSmcowen
AskWoody Lounger
-
-
-
Viewing 0 reply threads -

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
Rufus is available from the MSFT Store
by
PL1
3 hours, 47 minutes ago -
Microsoft : Ending USB-C® Port Confusion
by
Alex5723
5 hours, 56 minutes ago -
KB5061768 update for Intel vPro processor
by
drmark
2 hours, 10 minutes ago -
Outlook 365 classic has exhausted all shared resources
by
drmark
4 hours, 7 minutes ago -
My Simple Word 2010 Macro Is Not Working
by
mbennett555
1 hour, 42 minutes ago -
Office gets current release
by
Susan Bradley
4 hours, 19 minutes ago -
FBI: Still Using One of These Old Routers? It’s Vulnerable to Hackers
by
Alex5723
1 day, 18 hours ago -
Windows AI Local Only no NPU required!
by
RetiredGeek
1 day, 2 hours ago -
Stop the OneDrive defaults
by
CWBillow
1 day, 19 hours ago -
Windows 11 Insider Preview build 27868 released to Canary
by
joep517
2 days, 5 hours ago -
X Suspends Encrypted DMs
by
Alex5723
2 days, 7 hours ago -
WSJ : My Robot and Me AI generated movie
by
Alex5723
2 days, 7 hours ago -
Botnet hacks 9,000+ ASUS routers to add persistent SSH backdoor
by
Alex5723
2 days, 8 hours ago -
OpenAI model sabotages shutdown code
by
Cybertooth
2 days, 8 hours ago -
Backup and access old e-mails after company e-mail address is terminated
by
M W Leijendekker
1 day, 21 hours ago -
Enabling Secureboot
by
ITguy
2 days, 4 hours ago -
Windows hosting exposes additional bugs
by
Susan Bradley
2 days, 16 hours ago -
No more rounded corners??
by
CWBillow
2 days, 12 hours ago -
Android 15 and IPV6
by
Win7and10
2 days, 2 hours ago -
KB5058405 might fail to install with recovery error 0xc0000098 in ACPI.sys
by
Susan Bradley
3 days, 5 hours ago -
T-Mobile’s T-Life App has a “Screen Recording Tool” Turned on
by
Alex5723
3 days, 7 hours ago -
Windows 11 Insider Preview Build 26100.4202 (24H2) released to Release Preview
by
joep517
3 days, 2 hours ago -
Windows Update orchestration platform to update all software
by
Alex5723
3 days, 15 hours ago -
May preview updates
by
Susan Bradley
3 days, 2 hours ago -
Microsoft releases KB5061977 Windows 11 24H2, Server 2025 emergency out of band
by
Alex5723
2 days, 18 hours ago -
Just got this pop-up page while browsing
by
Alex5723
3 days, 7 hours ago -
KB5058379 / KB 5061768 Failures
by
crown
3 days, 4 hours ago -
Windows 10 23H2 Good to Update to ?
by
jkitc
2 days, 6 hours ago -
At last – installation of 24H2
by
Botswana12
4 days, 6 hours ago -
MS-DEFCON 4: As good as it gets
by
Susan Bradley
4 hours, 35 minutes ago
Recent blog posts
Key Links
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.