On my workstation I have developed a WinForm application. With panels, buttons and dropdowns.
After that I applied the application to my laptop.
On my laptop the presentation of the application was not correct. The elements overlap and the buttons are warped.
Can you tell me how to handle this?
I apologize for my english. This text was written with Google translator.
It is a bit difficult to tell from the distance, but I guess the window uses a different size on the laptop and the controls' docking and anchoring are not configured to do what you want. I suggest this and this tutorial on how to configure the properties; this is preferrably done in the designer instead of code for a fixed layout.
I've seen this behavior running Windows with a "display size" setting greater than 100%. Try resetting this value in your display settings:
Make sure to develop your forms on a computer with the system DPI setting set to 100%. Visual Studio will automatically convert your form coordinates depending on this system setting (it's a bug according to me). A quick way to fix a form is to do the following:
Make sure the system DPI setting is set to 100%.
Move a button in the form one pixel to the left. Then move it back again.
Save. Compile. Run.
1.] Either use Anchor or Dock
2.] Or try to fix the minimum and maximum size of your form and disable maximize button
Related
I'm having a problem that when i debug my application it doesn't match the size i've set in the designer. i've tried to set form minimum size to the desirable values.
The form is built up with a splitpanel, with a panel docked as fill on each side.
The labels have default anchors. Textboxes have anchors left,top,right.
Buttons have anchors left, top.
if i drag the bottom down during runtime i get the size/design i want, but why doesn't it start like that and how can i fix it?
Looks like you're working on quite a high resolution screen. Windows Forms isn't very good with scaling the content and has all kinds of quirks that you need to be aware of. I would move to WPF if possible, but if you really need to continue using Windows Forms, here's what you should do.
Use AutoScaleMode.Dpi on your main form. It'll scale and relocate the controls to match your design when the DPI of the monitor is higher than the default 96 (100%). You could also try AutoScaleMode.Font but it might not work well if you use fonts other than the default (Tahoma 8,25 pt or something like that).
Use TableLayoutPanel or FlowLayoutPanel to make positioning controls easier. FlowLayoutPanel dynamically lays down your controls horizontally or vertically. If you're familiar with WPF or Windows Phone development, it's basically a StackPanel control.
Make sure your screen DPI is 96 (100%) and keep it the same throughout the development. You'll still have to make sure to test the application on other DPI's so that users with different settings will be able to use your application.
Here's more information about DPI scaling:
How to configure an app to run correctly on a machine with a high DPI setting (e.g. 150%)?
How to control the font DPI in .NET WinForms app
Creating a DPI-Aware Application
Edit: Visual Studio's Windows Forms designer shows the form using a different theme than your Windows version so that's one reason why your form looks different in runtime. In runtime the form uses the theme of the operating system currently running the application.
i'm developing c# winform application, and having some sizing issues.
working env. :
developing on macbook, using vmware running windows 7, with visual studio.
also using infragistics winform controls.
the problem is that every time i'm opening the project, the size of the main form is changing, also the size of several controls in it is being changed.
so, i need to resize everything manually, before publishing the project.
this is very annoying, and i can't figure out what is causing this.
did someone here having the same issue, is there anything i can do to stop this?
thanks.
I have seen similar issues when windows default font size is changed in Control Panel Display settings. It probably has something to do with the Form's AutoScaleMode.
Is it changing by a lot or a little? Is it one pixel or is it a huge difference?
There were some known issues with UltraToolbarsManager in certain styles where opening the form in the designer changed the size of the form each time, but it was a very small change and it was consistent - meaning that the form would always get a little bigger or a little smaller each time.
These issues are all fixed in the latest version as far as I know.
So I've been coding a program for a little over a month now, and I've encountered a problem that I have no idea how to tackle. For a while now, I've always been confused when I opened up my program on other computer, and my window size was different. I chalked it up to a different resolution, and figured the problem would be easy to solve later. Then I imported a custom font to my program, and was confused when I noticed the letters where not clear and where blurry. I figured that this was something caused by my specified font size that I was using, and left it as is. Today however, as I was doing some testing I was annoyed by the blurry text enough to go and search online for the problem and solution, only to find out my problem lay within my DPI settings (125% on the computer I had mostly programmed on.)
I have no idea what I can do about this. I started programming a little while ago, and it was hard enough figuring out how to get the custom text working, but I just have no idea where to take this.
I've been coding this program in Visual Studio C# 2010 since it's the only version I've got that won't expire, so I can't use anything that might be in the 2011 or 2012 version.
All I want is for objects to be on the same place on one computer as another with a different DPI. Is there a very simple step-by-step tutorial somewhere that I can read or watch to figure this out?
This code snipshet worked perfectly for me.
http://urenjoy.blogspot.it/2008/11/make-resolution-independent-windows-app.html
(Using Visual Studio Express 2013)
It is required that windows app should have same layout at different resolutions means there should be no effect on layout of app on changing resolution. Here are the steps to do this.
Use table layout panel
Drag control in cell of tablelayoutpanel and set anchor and dock property.
Set rowspan and colspan properties of dragged control to merge cells
Set margin and padding of dragged control with respect to cell.
drag all controls and follow same steps, complete design using tablelayoutpanel
Now set all columns and rows size of tablelayoutpanel = autosize (or in %)
Set tablelayoutpanel properties autosize = true,autosizemode = grow and shrink
Set Forms properties autosize = true,autosizemode = grow and shrink
Run windows app If your windows app opens in maximum state then set tablelayoutpanel dock property =fill.
I can not figure out why my web form buttons change size when I run the web form from Windows 7 vs. Windows Server 2003. I have set the positioning and size on page load for all objects. Here is an example of a couple of the objects I am using.
Label1.Style.Add("Position", "fixed");
Label1.Style.Add("TOP", "20px");
Label1.Style.Add("Left", "50px");
btnQuery.Style.Add("Position", "fixed");
btnQuery.Style.Add("TOP", "370px");
btnQuery.Style.Add("Left", "198px");
The buttons have the same 3 entries. When I run this from my local Windows 7 PC, everything looks great. However, when I publish this to my Server 2003 site, the buttons are about 5 times longer and cover each other up. My label, textbox, and listbox are all fine as well. It is just the buttons. Is it because I am developing on Windows 7? Also, I am doing this in Visual Studio 2010, Framework 4.
They are changing because you are giving the size in pixels. If users have different screen resolutions, then it will change how large the buttons are in relation to the screen. Use relative sizing to fix this. This is not OS dependent, may just seem like it.
You're only setting the top/left position of the button, but not the size... If not specified, then web browsers are free to make buttons look however they want.
Assuming that this Style.Add method actually translates to CSS, try adding:
btnQuery.Style.Add("height", "120px");
btnQuery.Style.Add("width", "300px");
Then tweak those so its the size you want.
Generally, I'd advise against using fixed positioning at all, but that is a different story.
I have made a program within C# which i have now published from it but a problem occuyrs when i try to install it on different machines to mine. On my computer the program window size is fine but on other computers its sometimes too small and sometimes too big so the user can not properly look at the main screen of the program. I don't know what to do to change this problem, either within the computer settings or possibly in C# in the code of my project. Please Help,
Thanks,
Chris.
Use Dock and Anchor
It sounds like different users have different screen resolutions. Thats just part of developing software for a variety of users, with differing screen options. You should test your app is usable with different settings and possibly adjust font sizes, layout and dimensions accordingly.
If I'm guessing correctly the problem here isn't the screen resolution but that the actual program window changes size, either hiding parts of the program or showing too much? In that case you should take a look in your WPF editor (if you're using WPF, that is) and check the different Layout/Size options.
You need to use the Anchor properties and Dock properties of your controls (inside the form) to allow your program to be resized. If you can successfully resize it on your computer it should work on others too.
Part from that you may want to set the form to fixed size so that users can't resize it.
You can use the Screen class to get the bounds of the available screens, and from there you should be able to tell if your initial window size is too small and adjust it accordingly. You should probably take care to do this once on the initial launch of the application, just in case the user explicitly and intentionally moves/resizes the window so it doesn't completely cover the screen -- you wouldn't want to accidentally obliterate their changes the next time you run (assuming you even save window positions).