Windows Forms app looks different from Visual Studio designer view [duplicate] - c#

This question already has answers here:
How to configure an app to run correctly on a machine with a high DPI setting (e.g. 150%)?
(6 answers)
Closed 4 years ago.
I am trying to create a Windows Forms app using Visual Studio 2017. The app should be run on a 1024x768 touchscreen eventually, that is why I am trying to make all forms in size 1024x768 and without a form border. The problem is that when I launch the app the buttons seem to shift slightly and this makes them fall partially off the screen. The text also seems to be displayed in reduced quality and/or another size. You can look at the images below as an illustration of what I mean.
This is what the form looks like in the designer view in Visual Studio. The text is clear, everything fits the screen and all text fits in the buttons
Designer view of the form:
This second picture shows the form when I actually launch the app. The text quality is reduced, the 'Add From' text does not fit inside the button anymore and the bottom two buttons are partially off the form.
View of the form when app is launched :
My form is set to AutoScaleMode: Font, AutoSize: False.
Are these form parameters wrong or is it something in my Visual Studio settings? I have no clue what I could do to fix this.
Thanks in advance.

The resolution differences looks like a DPI issue. Windows Forms doesn't scale well to a DPI other than 100%. Check your monitor settings.
In Windows 10, this is labelled "Change the size of text, apps, and other items" in Display Settings.

Related

Location of controls different between designer and run [duplicate]

This question already has answers here:
How to configure an app to run correctly on a machine with a high DPI setting (e.g. 150%)?
(6 answers)
Closed 2 years ago.
Does anyone know why the location of some of my controls is different between designer and run mode? It's driving me nuts. In designer they are all in the right location, anchored as should be, but when I run the application, the form is somewhat resized but the controls don't move accordingly. The ones on the outer right are all somewhat hidden, and resizing the form in run mode does not improve this as they are anchored.
Thanks
Designer view
Run view
Configuring the application to use the correct dpi setting was the solution. Thanks Jimi! :)

Windows CE Form bug

I'm developing WinForm applications to Windows CE device. I have got a bug, on the top of the form(all form) have a 20 px height and full width zone, with topmost behaviour and Control color background, with cursor. On Visual Studio design mode can't see it just only on the device. Question is how to disappear it?
Thanks a lot
I'm willing to be that what you have there is a MainMenu with no MenuItems in it. It will show up as a blank strip across the top of the Form and cover any UI elements, but it won't show up in the designer.

testrun of form in visual studio c# shows a visible small scale version of it

i recently installed visual studio 2015 and made my first code in c#.
('maximized' for window state at the properties of the form)
everything went fine (comilation and testrun without errors) until i attempted to load one of the example tutorials, which i interrupted during loading.
after that i compiled and started my self coded application again from within visual studio. this time the output of the form was, unlike before, displayed half its size.
all the buttons including the window of the form appeared half its original size.
but when i executed the comiled application outside of visual studio (without it actually running) the application started in normal scale as intended.
this effect happens for this specific project only. if i start a new project the compilation & testrun will show a form scale as expected.
so my question: is there any magical setting that i have to change to end this nightmare ? i dont like to start all over again with a new project. i had set up 72 different button already. each buttonpress causes a different
SendKeys.Send("");
to be executed.
Check the Form's AutoScaleMode property!
The default is Font:
Controls scale relative to the dimensions of the font the classes are
using, which is typically the system font.
If that won't help do try to create a new project and copy the relevant cs-files into it!
In theory there is a zoom option in the VS designer, but at least in the Winforms desiner the shortcut does nothing for me.. It probably is for the WPF designer.
You did tag the question correctly and it is indeed about Winforms?

DPI changes of WinForm in C#

I have developed an application that controls couple of maxon motors in C#. My OS is Win 8.1. My program works properly. However, it has one strange behavior. When I press a specific button, the dpi (resolution) of the main form of the application highly increases and the size of the window decreases. So before pressing this button I have a windows with same dpi of other windows, and after pressing this button, I have a high resolution/small windows. I figured it out that the piece of code making this happened is:
Device.Init();
which is related to one of the maxon dlls. Does anyone know how I can remove this effect? Is there anyway to set resolution in Visual Studio?

Different Application Size On Different Screens [duplicate]

This question already has answers here:
.Net controls changing size between computers
(3 answers)
Closed 9 years ago.
First time i'm developing a Windows Form Application with C# . I'm using Visual Studio 2012.
My form's size = 1096x508. Also i set Minimum Size and Maximum Size properties to 1096x508 .
This is screenshot of my app ,
But when i execute this app on another computer, result like this :
As you see, red line (at bottom of app) invisible. Because applciation's height is 508 px (as expected) on my pc but 416px on other computer. Because of this , red line staying out of Form. So we couldn't see it.
In shortly, my Form's size 1096x508px but it's only 823x416px on another computer. Can you tell me why there are difference? And how can i fix this? There are resolution difference between this screens.
The behaviour of your application on those computers may be caused by different dpi (dot-per-inch) settings of the Windows operating system. In order to check that please compare the actuals values in Windows display settings (100%, 125%, ...).
If you want to have your program independent from dpi settings you may try to work with different panels (control containers). Your status bar could have a fixed with, while the game area is a docked panel (filling the remaining space).
In general, staying independent from actual dpi, is a difficult topic. Most of the time you can work with autosizing controls, but you could run out of space if, say, two labels overlay.
The main issue, as you have already discovered, is that computers with a different DPI setting will cause the controls to scale.
What Hans was suggesting in his linked answer is that you need to re-design your form so when it gets re-size messages it will handle them accordingly.
The main way this is normally handled is setting the Anchor property or the Dock property of a control. By default a control will anchor to the top left corner of it's parent container. When it is told to scale it scales down and to the right. By changing the anchor point to be the bottom only it will make your bottom control move up instead of moving down off of the boundaries of the parent.

Categories

Resources