listbox will disappear from my form when I resized the form

C

Claudia Fong

Hiya,

the listbox will disappear from my form when I resized the form.. is
there a way to prevent it? I want the listbox to auto resize when I
resize the form..


Cheers!

Claudi
 
J

Jeff Johnson

the listbox will disappear from my form when I resized the form.. is
there a way to prevent it? I want the listbox to auto resize when I
resize the form..

So do you mean that when you grab one of the edges of your form and change
its size by even a single pixel, the list box suddenly vanishes?
 
C

Claudia Fong

No, it disappear let says when you resize the half the original size...


Cheers!

Claudi
 
C

Cor Ligthert[MVP]

Claudia,

Have a look at the dock and/or the anchor properties of the listbox (or
better any control)

Cor
 
C

Claudia Fong

I tried listBox1.Anchor = AnchorStyles.Right;

listBox1.Anchor = AnchorStyles.Bottom;
listBox1.Anchor = AnchorStyles.Top;
listBox1.Anchor = AnchorStyles.Left;

And it still being cut off when resizing the form...

Don't understand..

Cheers!

Claudi
 
J

Jeff Johnson

I tried listBox1.Anchor = AnchorStyles.Right;

listBox1.Anchor = AnchorStyles.Bottom;
listBox1.Anchor = AnchorStyles.Top;
listBox1.Anchor = AnchorStyles.Left;

And it still being cut off when resizing the form...

Don't understand..

It sounds like, for example, you have some controls on the left side of the
form and a list box on the right side of the form. When you make the form
narrower, you want these controls to resize proportionately so that they all
remain visible. I don't think you can do this with the Anchor property;
instead I believe you either need to use one of the layout controls that
were introduced in Windows Forms 2.0, like FlowLayoutPanel or
TableLayoutPanel, or else you'll need to do it the old-fashioned way and
write resizing code yourself. I've never used the two controls I just
mentioned, so I can't tell you much about them or if they'll even work. I
can tell you that the "manual" approach always works, but it's definitely
more effort.
 
C

Cor Ligthert[MVP]

You mean that the box becomes so small after resizing that there cannot be
any box anymore?

Probably is the dock property what you are searching for.

Cor
 

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