How to display listbox (or other control) on top of the parent form

G

Guest

Hi, all winform experts

If I add a listbox control on a form, when the size of the form decreases and the height of the form is less than the height of the listbox, part of listbox will be hidden.
However if I add a combobox to the form, when the combobox is clicked, all the items can be seen even the height of the form is less that the height of the combobox. Does someone know how to make the items in the listbox displayed all the time (just like combobox) ?
Do I need to draw the listbox ? or is there any property I need to set

Thanks
Jac
 
J

Jeremy Williams

Jack said:
Hi, all winform experts,

If I add a listbox control on a form, when the size of the form decreases
and the height of the form is less than the height of the listbox, part of
listbox will be hidden.
However if I add a combobox to the form, when the combobox is clicked, all
the items can be seen even the height of the form is less that the height of
the combobox. Does someone know how to make the items in the listbox
displayed all the time (just like combobox) ?
Do I need to draw the listbox ? or is there any property I need to set?

Thanks,
Jack

If you dig down into the inner workings of the Windows Forms combo box, you
will find that the drop-down portion of the control is displayed on a
separate form when the button on the combo-box is clicked. That is how the
combo box appears to go outside it's host form.

So, to get a list box to display "outside" the form, you would need to put
the control on a borderless form, and include code to make sure it stays
positioned over the "host" form. This would not be a quick thing to code.

Out of curiosity, why do you want the list box to work this way? It is
definitely non-standard windows behavior.
 
G

Guest

Thanks for the tip.
The reason I need to do this is I need to use a fix sized winform control on a webpage. However if I have a listbox at the bottom of the page, it is only partially seen

----- Jeremy Williams wrote: ----


Jack said:
Hi, all winform experts
and the height of the form is less than the height of the listbox, part o
listbox will be hidden
However if I add a combobox to the form, when the combobox is clicked, al
the items can be seen even the height of the form is less that the height o
the combobox. Does someone know how to make the items in the listbo
displayed all the time (just like combobox)
Do I need to draw the listbox ? or is there any property I need to set

If you dig down into the inner workings of the Windows Forms combo box, yo
will find that the drop-down portion of the control is displayed on
separate form when the button on the combo-box is clicked. That is how th
combo box appears to go outside it's host form

So, to get a list box to display "outside" the form, you would need to pu
the control on a borderless form, and include code to make sure it stay
positioned over the "host" form. This would not be a quick thing to code

Out of curiosity, why do you want the list box to work this way? It i
definitely non-standard windows behavior
 

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