Combo Like User Control

J

Jeff Gaines

I am putting together a control which will work like a combo box - except
its drop down will be a Tree View.

When I use the control in a panel on a form I can't resize it to allow for
the drop down part - it is constrained by the size of its parent panel -
yet a combo Box can open up and without any such constraints.

Is there a trick to allowing a control to open up (temporarily) over other
controls? I seem to remember from a while back that this could be achieved
by placing the control on a borderless form, but it seems a lot of work
when all I need is Combo like behaviour.
 
S

Stoitcho Goutsev \(100\)

Controls are child windows they are clipped by the size of theur parent.
Popup windows are not on the other hand. AFAIK using forms is probably the
only way you can pull this off with WindowsForms.
 
J

Jeff Gaines

Controls are child windows they are clipped by the size of theur parent.
Popup windows are not on the other hand. AFAIK using forms is probably the
only way you can pull this off with WindowsForms.

Thank you, Stoitcho - at least I understand why now :)
 
L

Linda Liu [MSFT]

Hi Jeff,

The drop down part of a ComboBox control is a separate window, which
enables the drop down part to open up over other controls.

To implement a custom drop down window, we could use a WinForm, whose
FormBorderStyle property is set to None. But this solution is not very
good, because the form would take the focus and inactivate the main window
form. The functionality of the dropdown would be difficult to manage too.

A better solution is to derive a class from NativeWindow and create a popup
window, similar to a tooltip window, that can be shown using the
SW_SHOWNOACTIVATE setting and ShowWindow function via interoop. A class
created in this way would mimic the behaviour of the base Win32 controls
and it would be easier to create the desired internal functionality such as
item selection and so-on.

You may visit the following link for more information on how to do it using
NativeWindow.

http://vbaccelerator.com/home/NET/Code/Controls/Popup_Windows/Popup_Windows/
article.asp

I searched the web site ' www.codeproject.com' and also found a smarter
solution of using ToolStripDropDown to implement the drop down window. You
may visit the following link for more information on how to do this.

http://www.codeproject.com/useritems/simplepopup.asp

Hope this helps.
If you have any question, please feel free to let me know.


Sincerely,
Linda Liu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
J

Jeff Gaines

Hi Jeff,

The drop down part of a ComboBox control is a separate window, which
enables the drop down part to open up over other controls.

[snipped]

Many thanks, Linda - they are very useful examples :)
 
L

Linda Liu [MSFT]

Hi Jeff,

Thank you for your prompt response.

How about the your implementing the custom drop down window? If you need
our further assistance, please feel free to let me know.

Thank you for using our MSDN Managed Newsgroup Support Service!


Sincerely,
Linda Liu
Microsoft Online Community Support
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top