Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Usercontrol & SetParent() function

Hello,
I created a new user control that has a similar look & feel to the properties frame in the VB6 IDE. Its basically a flexgrid with a few hidden textboxes & listboxes. I have everything working great, but I have one last glitch:
In order to make a hidden listbox "pop out" of the control, I set the listbox's parent to the form that the user control is on. This works great, but it has one undesireable side affect- the listbox takes on the PARENT FORM's BACKCOLOR! Even explicitly setting the listbox's backcolor to vbWhite or whatever will not change the listbox color. If the form is buttonface, green, or purple, so is the listbox. If anyone has an idea on this one, I'd really appreciate it. I thought that an alternative might be this:
Put the listbox on a picturebox, and set the picturebox parent to be the main form. That way the list would just be along for the ride, but I would probably need to do a bunch of "fudging" to control the picturebox size.
Thanks, Mike
[1024 byte] By [mikkojay] at [2007-11-11 8:17:22]
# 1 Re: Usercontrol & SetParent() function
as I understand correctly, the problem is that the listbox myst appear on top of the control, but it can overlay outside the control region. It is also true that even reparenting the listbox, it will not be able to expand outside the main form itself, so potentially you can end up with a partial listBox (if the usercontrol is at the bottom of the parent)

did you try to put the list box in a bordless Form, and showing this form modally?
What about using a combo with a drop down list? or a menu?

PS what you see is normal. probably you are using an API to reparent the listbox, and therefore you are doing it "behind" VB6, that does not know it, and therefore setting the background of the listbox does not work

Marco
mstraf at 2007-11-11 17:25:45 >
# 2 Re: Usercontrol & SetParent() function
I would probably just buy a third-party property list control. ;-)

http://www.vbthunder.com/software/proplist/
Phil Weber at 2007-11-11 17:26:44 >