views:

108

answers:

1

Hi,

I have a normal Form control and in the CTOR function I have the following :

this.Region = System.Drawing.Region.FromHrgn(WinUser.CreateRoundRectRgn(0, 0, this.Width, this.Height, 16, 16));

Later in my App I create a ListBox object and show it at the bottom of my parent form, but the listbox size is bigger than my form and therefore the bottom half of the ListBox which is outside the Parent Form region gets clipped.

Is there any way around this, that is I do not want the form size to be increased instead I want the Listbox to show completely even if it is bigger than the form.

anand

+2  A: 

This kind of feat can only be accomplished if you create a window that's allowed to extend past the boundaries of the form. Windows supports this, the dropdown list of a combo box would be an example. Windows Forms however doesn't care much for it. Check my code in this thread to see how it's done.

Hans Passant
Thanks, I'll give it a try. Could you tell me what does "SetBoundsCore" do?And when is "public new Point Location" called?
Anand
These are properties and methods of the Control class that are documented in the MSDN Library. Look there first.
Hans Passant
Thanks nobug I tried this and it worked perfectly. The only problem I am having now is that the new ListBox gets focus and my parent form gets deactivated. As per my design for my APP I do not want that. I needed to show/setTopLevel from my parent form for that to work(with some flagging mechanism). As setTopLevel is a protected member of a control I could not directly call it from my parent form and used a crude indirection to call a public function in my listbox object. Is there any way around that are setTopLevel must be called to show the control?
Anand
This should not happen, there's something wrong with the Parent property of that list box. Make sure the form is the parent.
Hans Passant