We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now


Turning off border of a Listbox in VB6?

steveuci asked
Medium Priority
Last Modified: 2013-11-13
I'm finding it strange that I can't adjust the borderstyle of a VB6 listbox.  I want to turn it off so that it is not visible and so that the listbox can blend in with the surrounding background color.   Anyone know how this can be done?  

I'm not opposed to seeing a solution using Win32 API to accomplish this.

Thank you for your time!
Watch Question

WOW, thats crappy...

Best I can think of... Use a Line (set the width to a couple of pixels to make it easier
make the line the background color of your listbox, then position right on top of the border, should make it look like the inside of the listbox (making it appear 1 or 2 pixels higher) but should hide the border :)

The Windows API solution to this would be to remove the WS_BORDER style from the list box when it created by the CreateWindow() call. It might also be possible to change this style using Get/SetWindowLong(), although the docs don't explicitly say that this style can be changed after the window is created.

I don't know vb6 well enough to know if you can tie into the control creation and remove the WS_BORDER style, though.


Kavar, I thought about doing something like that, with a box shape control, but for some reason both that box shape and your Line idea can't seem to rise above a listbox control z-order-wise; the line always gets hidden by the listbox no matter what.  So that can't work as a workaround unfortunately, so I'll hold out for a more concise solution.

wayside, I'll experiment a little bit with your ideas and see what can be done.  

Any other ideas?

okay then... if nothing else pans out... (I don't think you can change window styles once they are created)

create a text box without a border, place it on top of listbox, whenever getfocus or mousedown or keydown, send them to listbox, whenever listbox changes update textbox text

your other (more techinical, probably better solution, is to create a borderless list box class...)
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview

Glad it worked.

MSDN is not clear on whether the border can be changed after the window is created, but apparently you can. :)


Well well well!  That's fantastic!   Works like a charm :D

Thanks Kavar!  I'll accept your answer as the solution, but will try to give credit to wayside for mentioning the Get/SetWindowLong first.


^ Hmm, not sure if that's even possible -- I'm new to experts-exchange and don't see a way to assign credit to multiple contributors!   Sorry to wayside, you were on the right track at least.

Thanks again Kavar.

>Sorry to wayside, you were on the right track at least.

Not a big deal.

But just so you know, you can split the points between different contributors when you go to accept an answer. See here for details:

Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.