views:

643

answers:

2

Hi

I am attempting to create my own custom Autocomplete style dropdown control in c# .net2.0. For speed of development I have built my control as a UserControl but have hit on an issue of doing it this way.

When the custom drawn dropdown gets drawn I have to resize the UserControl area to be able to display the list of options.

Ideally I want to be able to mimic the drodpown list behaviour in that the list of options is drawn 'floating' and is not constrained by the UserControls height and width (nor even the parent forms boundaries). A tooltip is another example of the unconstrained 'floating' that I desire.

The only way I can think of achieving this is to create on the fly a new form with no border or title bar and display this when the popup is required.

Is there a better (but also quick) way of doing this?

TIA

+1  A: 

You would need to use a Form or NativeWindow to allow the control to float correctly. To make a form follow the control is easy enough but it is more difficult to implement and handle all of the focusing/hiding issues especially if you need seamless tabbing/key navigation.

Steven
+1  A: 

You can try creating a control that is based off the ToolStrip Drop Down Button control. I believe that this control has the functionality that you are looking for. I found this reference for creating controls based off the ToolStrip, you might try starting with this.

http://blogs.msdn.com/jfoscoding/attachment/1335869.ashx

Joe.Ingalls