Different Form Size on different PCs (What can i DO????)

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I've created a program in C#, which includes several Forms. some of the forms
are in different size, but i start all of them in Window Normal Size.
I took the exe file from the \bin\debug library and started it on my
computer and all the forms where at the same size as i programed it to be.
then i took it to my friend's PC and it worked fine too (we both have NVIDIA
display card), then i took it to another computer (with different display
card) and there the form where not at the same size as i programmed. Some
were too big (came out of the screen's border). Is it possible that different
display cards make the forms to be displayed differntly? I asked some
friends, and they told me that C# suppose to know how to handle such things
automaticly.
What can I do, to fix this problem? because i want to put my program on
several PCs and i don't know which display card they'll have.

Thanks,
Gidi.
 
The size of a window is measured in pixels. Different computers have
different screen resolutions. You would need to get the pixel size of the
screen and resize the form accordingly in order to do this.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
You can lead a fish to a bicycle,
but you can't make it stink.
 
thanks Kevin,
even when i changed the resolution of the problematic screen to same as
mine, it still didn't work well.
 
This might be overkill, but I set the Dock property to most of the controls
on my form. In my opinion, it is much more dynamic, flexible, and automated
than trying to handle resize events. Usually, I dock everything to the top
and/or bottom of a form and set the app's main workspace to Fill. If I don't
want a control, like a button or textbox, to stretch the entire width of
the control, I group these controls in Panels and set Panel.Dock. In my opinion,
docking is much more powerful than Anchor because it ensures that controls
stay adjacent to other controls.

You should also play with .NET 2.0 flow layout panel.
 
Probably your friend increased the font size in his appearnce settings
of the desktop, that has sometimes weird effects on statically designed
windows as buttons become too small and so forth.
 
Probably your friend increased the font size in his appearnce settings
of the desktop, that has sometimes weird effects on statically designed
windows as buttons become too small and so forth.

I just tried this. The forms title bar grew, but the other controls (label,
button, checkbox) were completely unaffected. The title bar grew "up" so it
didn't cause problems by pushing controls down off the bottom of the form
either.
 
Dan said:
I just tried this. The forms title bar grew, but the other controls (label,
button, checkbox) were completely unaffected. The title bar grew "up" so it
didn't cause problems by pushing controls down off the bottom of the form
either.

Do not change the font size in appearance settings, instead go to
Settings->Advanced and change DPI Setting. This is the setting that has
weird consequences for values other than 96.

Also see the documentation for the AutoScale (1.1) and AutoScaleMode
(2.0) properties.

HTH,
Stefan
 
Try this code

this.AutoScaleDimensions = new
System.Drawing.SizeF(this.CurrentAutoScaleDimensions.Width,
this.CurrentAutoScaleDimensions.Height);
this.FormBorderStyle = this.AutoSize = false;
System.Windows.Forms.FormBorderStyle.FixedSingle;
 
Back
Top