I have a user control that has this structure from top to bottom:

Label1
Label2
PictureBox1
Label3
PictureBoxes2 through 11

All of the controls are anchored Top,Left. Pictureboxes 2 through 11 are
right next to each other in the designer, with 1 pixel of space between
them.

This user control is added to a form that has this structure:

Form
TopLevelSplitContainer
TopLevelSplitContainer.Panel1
other stuff
TopLevelSplitContainer.Panel2
justAPanel
myUserControl
aDGV

Depending on something happening in the background, it displays the
UserControl or the DGV.

The problem is when I the UserControl is displayed in my form, it spaces out
pictureboxes 2 through 11 and ends up chopping off the right side of the
last picturebox.

I am adding the UserControl programmatically, but even if I just drop it on
the justAPanel in the designer, it does the same thing.

If I don't anchor the controls on MyUserControl at all, they don't spread
correctly vertically, and they are actually wider horizontally than they
would be if I anchored them.

When added programmatically to the form, the usercontrol is set to dock Left
and Top. If I don't dock it, it seems to center it, which chops off both
sides of the usercontrol.

Any ideas why my controls are being rendered differently in run mode than
they are in design mode?

My containing form is a user control, too, by the way, which does sit in an
actual Form that has a minimum size and a default size that this panel
should fit into if it weren't mucking up my picturebox locations.

The reason I have 10 picture boxes is because each one has its own click
event. Just thought I'd throw that in there before someone says "Why don't
you just combine the picture boxes into one?".

Sorry for the cross-posting; I'm desperate.

Thanks in advance.
RobinS.
GoldMail.com

Re: Pictureboxes moving on their own volition when form is displayed by RobinS

RobinS
Fri Mar 14 14:12:48 CDT 2008


"RobinS" <robins@imnottelling.com> wrote in message
news:DOGdnfnFneloJUfanZ2dnUVZ_sudnZ2d@comcast.com...
>
> I have a user control that has this structure from top to bottom:
>
> Label1
> Label2
> PictureBox1
> Label3
> PictureBoxes2 through 11
>
> All of the controls are anchored Top,Left. Pictureboxes 2 through 11 are
> right next to each other in the designer, with 1 pixel of space between
> them.
>
> This user control is added to a form that has this structure:
>
> Form
> TopLevelSplitContainer
> TopLevelSplitContainer.Panel1
> other stuff
> TopLevelSplitContainer.Panel2
> justAPanel
> myUserControl
> aDGV
>
> Depending on something happening in the background, it displays the
> UserControl or the DGV.
>
> The problem is when I the UserControl is displayed in my form, it spaces
> out pictureboxes 2 through 11 and ends up chopping off the right side of
> the last picturebox.
>
> I am adding the UserControl programmatically, but even if I just drop it
> on the justAPanel in the designer, it does the same thing.
>
> If I don't anchor the controls on MyUserControl at all, they don't spread
> correctly vertically, and they are actually wider horizontally than they
> would be if I anchored them.
>
> When added programmatically to the form, the usercontrol is set to dock
> Left and Top. If I don't dock it, it seems to center it, which chops off
> both sides of the usercontrol.
>
> Any ideas why my controls are being rendered differently in run mode than
> they are in design mode?
>
> My containing form is a user control, too, by the way, which does sit in
> an actual Form that has a minimum size and a default size that this panel
> should fit into if it weren't mucking up my picturebox locations.
>
> The reason I have 10 picture boxes is because each one has its own click
> event. Just thought I'd throw that in there before someone says "Why don't
> you just combine the picture boxes into one?".
>
> Sorry for the cross-posting; I'm desperate.
>
> Thanks in advance.
> RobinS.
> GoldMail.com
>
>

So here is what I figured out through trial and error.

The panel on which my controls sit has an AutoScaleMode of "Font".
Apparently when it renders, it scales up and repositions everything on the
screen, which includes spacing the graphics out. When I set this to "None",
the graphics stay in place.

This is a little frustrating, because I have been tasked with changing all
of the forms (and underlying user controls) to display correctly on a
computer running "big fonts" (dpi=120). Right now, our app only looks right
on 96-dpi setting.

Before you post back and say "set autoscalemode to dpi", I'll pass on that I
tried that, and I think the problem I'm having is that the distance on our
splitter controls is hardcoded, as well as the default size of our
application, and apparently I'm going to have to do some math to fix that
problem. We don't want the user to be able to change the splitter position.

Also, from what I've read about AutoScaleMode, if you set it to "Font", it
will scale for both Font and DPI changes. We are not currently really
supporting international users (many have our product, but it's all in
English for the moment), but when we do, I assume I'm going to want the
forms to scale by Font as well as by DPI.

If anybody has any wisdom about the whole AutoScaleMode topic, I'd love to
hear it, as this is looming quite large on my to-do list.

Thanks very much.

RobinS.
GoldMail.com