+ Reply to Thread
Results 1 to 11 of 11

changing the backcolor of a listbox

  1. #1
    Registered User
    Join Date
    04-03-2015
    Location
    Hong Kong
    MS-Off Ver
    2013
    Posts
    8

    changing the backcolor of a listbox

    hi guys,
    got a problem for changing the backcolor of a listbox
    heres the situation
    a listbox consists around 20 items and the backcolor is yellow in the beginning, once users click and select an item in listbox, it will immediately changing from yellow to white.
    i've tried using AfterUpdate events but seems that it will automatically de-select the selected item.
    are there any way to solve it?
    thanks

  2. #2
    Registered User
    Join Date
    11-16-2013
    Location
    Indonesia
    MS-Off Ver
    Excel 2010
    Posts
    30

    Re: changing the backcolor of a listbox

    Can you upload some file for example?

  3. #3
    Registered User
    Join Date
    04-03-2015
    Location
    Hong Kong
    MS-Off Ver
    2013
    Posts
    8

    Re: changing the backcolor of a listbox

    i've uploaded an example for testing..
    many thx
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    05-08-2015
    Location
    Bangalore,India
    MS-Off Ver
    Microsoft office 2010
    Posts
    4

    Re: changing the backcolor of a listbox

    i got solution for ur problem...in list box properties , change the back color, and dont do any other changes
    Attached Files Attached Files
    Last edited by shailendra.nr; 05-08-2015 at 04:11 AM. Reason: updated

  5. #5
    Registered User
    Join Date
    11-16-2013
    Location
    Indonesia
    MS-Off Ver
    Excel 2010
    Posts
    30

    Re: changing the backcolor of a listbox

    You can use Enter and Exit Declarations.

    Please Login or Register  to view this content.
    but you must add other tools, like textbox or combobox or button, for Exit declaration work with it.

  6. #6
    Registered User
    Join Date
    04-03-2015
    Location
    Hong Kong
    MS-Off Ver
    2013
    Posts
    8

    Re: changing the backcolor of a listbox

    Quote Originally Posted by shailendra.nr View Post
    i got solution for ur problem...in list box properties , change the back color, and dont do any other changes
    thanks for your reply but i didnt get it
    the color properties is for reminding user to select the item, once an item is selected, it should no longer remain yellow

  7. #7
    Registered User
    Join Date
    04-03-2015
    Location
    Hong Kong
    MS-Off Ver
    2013
    Posts
    8

    Re: changing the backcolor of a listbox

    Quote Originally Posted by ferry2512 View Post
    You can use Enter and Exit Declarations.

    Please Login or Register  to view this content.
    but you must add other tools, like textbox or combobox or button, for Exit declaration work with it.
    thanks for your suggestion, but are there any ways to make it update automatically?

  8. #8
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: changing the backcolor of a listbox

    Does not look like the property refreshes when used in events other than x_Update.

    Perhaps you could use an alternative approach such as drawing a box around the control.
    Attached Files Attached Files
    Cheers
    Andy
    www.andypope.info

  9. #9
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,525

    Re: changing the backcolor of a listbox

    Hi kweep,

    Yes there does seem to be an issue trying to change the background colour via the click event on a listbox. Andy had also pointed the issue here.

    That said, try this work around as changing the background colour using the AfterUpdate event seems to work fine:

    Please Login or Register  to view this content.
    Regards,

    Robert
    ____________________________________________
    Please ensure you mark your thread as Solved once it is. Click here to see how
    If this post helps, please don't forget to say thanks by clicking the star icon in the bottom left-hand corner of my post

  10. #10
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: changing the backcolor of a listbox

    Can't belive it's almost 10 years since I answered that and with the same solution even!

  11. #11
    Registered User
    Join Date
    04-03-2015
    Location
    Hong Kong
    MS-Off Ver
    2013
    Posts
    8

    Re: changing the backcolor of a listbox

    Quote Originally Posted by Trebor76 View Post
    Hi kweep,

    Yes there does seem to be an issue trying to change the background colour via the click event on a listbox. Andy had also pointed the issue here.

    That said, try this work around as changing the background colour using the AfterUpdate event seems to work fine:

    Please Login or Register  to view this content.
    Regards,

    Robert
    Hi Trebor76,

    it works fine if there are small number of item in the listbox, however if there are many items which required to use a scroll bar, then those items down below are not able to selected...i doubt if this problem is unable to solved..

    i will use Andy's alternative for this issue, many thanks for all your effort!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Listbox Selection/Highlight is lost after changing Listbox BackColor
    By mc84excel in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-02-2014, 10:43 PM
  2. Changing BackColor on all Forms
    By frogger750 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-07-2012, 10:20 PM
  3. Changing Button BackColor
    By Mordred in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-21-2011, 07:12 PM
  4. [SOLVED] Changing BackColor on Command Buttons?
    By RBee in forum Excel General
    Replies: 0
    Last Post: 08-15-2006, 01:25 PM
  5. multiselect listbox backcolor
    By Russ in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-01-2005, 07:05 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1