Making size of control = size of form

  • Thread starter Thread starter Derrick
  • Start date Start date
D

Derrick

Hello all;

I'm trying to simulate a "scrollable context menu". What I want is to have
a listbox fill the entire area of a small form (with no border).

Using the designer and property grid, I noticed that if I set the form size
first, then try to copy and paste this value into the size of the listbox
(making sure the listbox is in location 0,0 first), the designer won't let
the listbox fill the entire form area - there are 9 pixels of the form at
the bottom still showing (when you paste the size value in for the listbox,
watch how 9 is magically subtracted from the height).

If I go the other way, and set the size of the listbox first, then paste
that value into the size of the form, it works OK.

Can anyone explain the difference to me? I think it might have something to
do with the absence of the title bar - there seems to be a 4x4 pixel border
around that, which is probably left behind when I set border style to
"none".

Also, when I try to create the listbox in code, the 9 pixels always show,
regardless of whether I set the size of the form or listbox first.

Thanks for any info,

Derrick
 
Not sure about the form stuff, but it sounds like what you really want is a
UserControl, not a form. If you put a control onto a UserControl, then set
the "Dock" property to "fill", it will fill the entire area of the control.
You can show and hide that and move it wherever you want, even add
properties to it.

-Rachel
 
Why are you not setting the dock property to fill? Also, you need to turn of
the integral height, which will always make the listbox display whole items,
not partial items, that's what causing the automatic resizing you
experience.

You should post this to the windowsfoms newsgroup.

Etienne Boucher.
 
I was using the dock property, but that yielded the same effect as sizing.
The integral height should be the fix I was missing - thanks a lot!

BTW: for some reason, my newsreader doesn't see the windows forms newsgroup,
hence my posting here. Sorry.

Derrick
 
Thanks Rachel. That would be a better solution, except that I never
mentioned that I wanted this to work on both the Framework and Compact
Framework. In order to get the overlay effect I wanted on CF, I had to use
a form.

Appreciate your help,

Derrick
 
Back
Top