Windows Develop Bookmark and Share   
 index > Windows Forms Designer > Help about popup control
 

Help about popup control

I have created a popup control (derived from Control) and host (attach) 1 listbox to this popup control (obvious I will set property Dock of listbox to Fill)

PopupControl _popup = new
 PopupControl();
ListBox listbox = new
 ListBox();
listbox.Dock = DockStyles.Fill;
_popup.Controls.Add(listbox);


I override CreateParams on PopupControl to style:
protected
 override
 CreateParams CreateParams
            {
                get

                {
                    const
 int
 CS_DROPSHADOW = 0x00020000;
                    const
 int
 CS_NOCLOSEBUTTON = 0x200;
                    const
 int
 CS_NOVERTICALSCROLLBAR = ~0x200000;

                    CreateParams cp = base
.CreateParams;
                    if
 (mParent != null
 && !DesignMode)
                    {
                        cp.Style = (int
)(((long
)cp.Style & 0xffff) | 0x90200000);

                        cp.Style &= CS_NOVERTICALSCROLLBAR;

                        cp.ClassStyle |= CS_DROPSHADOW;

                        cp.Parent = mParent.Handle;
                        Point pos = mParent.PointToScreen(Point.Empty);
                        cp.X = pos.X;
                        cp.Y = pos.Y + mParent.Height;
                        cp.Width = this
.DefaultSize.Width;
                        cp.Height = this
.DefaultSize.Height;
                    }
                    return
 cp;
                }
            }

But when popup is displayed, it appear a space at the bottom, please see my captured image:
http://img24.imageshack.us/img24/4107/94256039.png

I think I need to modify CreateParams a little but I don't know how to do.
Please help me to disable the unwanted space. Thanks.

Le Vo Quang  Friday, September 18, 2009 5:08 AM

Hi,

The remained part is because listbox.IntegralHeight property. The default setting of IntegralHeight property is true. Listbox will automatically resize to make sure an item is not partially displayed. Setting listbox.IntergralHeight to false will be ok.

listbox.IntegralHeight = false;

ListBox.IntegralHeight Property

Gets or sets a value indicating whether the control should resize to avoid showing partial items.

http://msdn.microsoft.com/en-us/library/system.windows.forms.listbox.integralheight.aspx

Best regards,

Ling Wang


Please remember to click “Mark as Answer�on the post that helps you, and to click “Unmark as Answer�if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
Ling Wang  Thursday, September 24, 2009 12:11 PM

Hi,

The remained part is because listbox.IntegralHeight property. The default setting of IntegralHeight property is true. Listbox will automatically resize to make sure an item is not partially displayed. Setting listbox.IntergralHeight to false will be ok.

listbox.IntegralHeight = false;

ListBox.IntegralHeight Property

Gets or sets a value indicating whether the control should resize to avoid showing partial items.

http://msdn.microsoft.com/en-us/library/system.windows.forms.listbox.integralheight.aspx

Best regards,

Ling Wang


Please remember to click “Mark as Answer�on the post that helps you, and to click “Unmark as Answer�if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
Ling Wang  Thursday, September 24, 2009 12:11 PM

You can use google to search for other answers

Custom Search

More Threads

• Scrollbar in Control Panel. please help
• A bug in MSDN sample: DesignerHost.exe
• Having issues with VS 2005 designer
• best way to implement a simple designer for user defined fields
• Designer Fails to Show From after VS 2003 Port
• Control-wide events for custom user controls
• Menus in Inherited forms
• textbox accepts 0.99 to 99.99
• How can I implement the property DataBindings in a Smart Tag of a control
• CD Autorun - Want to create a button browser on my cd