Winform Automatic Resizing

A

Action

I put a picture box in the center (fill) of a form
and put a toolbar at the bottom.

a picture will be loaded @ run time
I can get the form resized automatically.
I tried to use
form.Size = picturebox.Size
butthe toolbar is blocking part of the picture....

any automatic sizing (like java?)
?
thx
 
P

Pete

Hi,
any automatic sizing (like java?)

The Dock property should do what you want. If that fails (it shouldn't) then
use Anchor.

There are some attempts at making java style layout managers for c# on the
web. I don't think any of them are very complete though.

-- Pete
 
P

Pete

Hi,
I already docked it in the center of the winform, it don't resize
automatically.

That isn't possible.. perhaps you mean DockStyle.Fill? And is the toolbar
docked as well?

A google search would probably help a great deal.

-- Pete
 
K

Kellye Gaskill

Docking will only resize the picturebox to the form.

It sounds like what you want to do is resize the form to the picturebox
(which I assume is auto-sized by the image file).

Dock the toolbar to the bottom of the form.
Anchor the picturebox to the top & left (default), with no docking.

Then in the appropriate event (after the picturebox has changed size), do:
form.Width = picturebox.Width
form.Height = pictureBox.Height + toolbar.Height

That's very close to what you were doing, but you weren't accounting for the
toolbar height, so it was obscuring part of the picture.
 

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