winform and control size is changed by itself - c#

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.

Related

Why my WinForms appear all congested in [Design] mode VS2015

I am developing my app on two different PCs, both having Windows 10 and Visual Studio 2015 installed using the same installers. When I open some of my WinForms in lab PC, the controls included in the WinForms appear all congested together (and even overlapping each other) making it impossible for me to modify the visuals. This happens only in "design mode". When i run the app, all forms appear correctly. Kindly see the difference in attached pic
This happens only for a few of the forms, not all. But despite comparing each and every form property (including "AutoScaleMode" which is set to "Font" for each form), i couldn't locate the cause. The other PC is showing all the forms 100% correctly in design mode.
What could be the possible reason/solution?
EDIT: Solution discussed here also has no effect in my case, whereas other posters said that their issue was resolved by changing the DPI-awareness of their PC.
This happens when your application is not responsive to different sizes of the display! you need to set the Anchor and Dock properties in winform.
Make it responsive but the best solution is to develop the application on WPF.
Thanks

Show C# WinForm on different screens

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

Easy way to do DPI scaling?

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.

WPF form displaying as winform

Sorry this is probably a really silly question but I am developing a WPF form on a Windows 7 machine with VS2010 yet when running the application the form still looks like a standard WinForms window.
I am assuming that it requires an extra component installed on the system to be displayed as shown in the designer?
PS: To be more specific what I am referring to is basically the outline and border.
No, what you are experiencing is totally normal. Unless you have altered the default style of your controls, your application will be drawn using windows default look and feel.
That border is just for design purposes. But you could add your own Border to recreate it during runtime.

visual studio 2005 designer moves controls and resizes Form

When i open a form in visual studio 2005 (c#) the designer automaticaly resize the form and move/resize controls without touching the designer at all. The source file is changed and when i close the designer i'm asked to save the *.cs file.
I tried to look into visual studio options without any success.
any ideas?
visual studio setup or something?
thanks,
Tal
I have been working on this problem for most of today and found some interesting things: The main source of the problem seems to be relying on anchoring. If I use docking to position my controls, instead of anchoring, my problems seem to go away. I found a couple of blog posts from 2003(!), which detail how you might use docking instead of anchoring, and explain how anchoring can break the Windows Forms designer. It seems like this problem might be over 7 years old!
Here are the posts:
http://weblogs.asp.net/rweigelt/archive/2003/09/24/28984.aspx
http://weblogs.asp.net/rweigelt/archive/2003/10/17/32407.aspx
http://weblogs.asp.net/rweigelt/archive/2003/10/23/33181.aspx
This is due to AutoScaleMode-property. Your forms have probably been designed with a different DPI or Font settings than you have now in Windows display settings. AutoScaleMode-property has 4 different possible values : Dpi, Font, Inherit or None. In Dpi or Font mode, your forms and controls will be automatically resized depending on windows display settings.
So, set the AutoScaleMode-property to None in all your forms and controls and they won't be automatically resized anymore. Try to design your forms in order to let sufficient space in every controls so that text will fit even if text size is set to 125%.
I found a work around.
not sure what happens behind but i changed my display properties. and it works fine.
here is the sequence: display propertis->settings tab->advance.
in the the advance dialog i changed the "DPI Settings" from Large (120dpi) to Normal (96 dpi)
Had the same problem with controls anchored top, left and right within complex TabControls. The visual studio forms designer was increasing the width of all nested controls each time I would open the form.
I found a simple workaround thanks to this post. I simply added a panel to each tab and set their dock property to fill. All existing controls within the tabs were moved inside those panels. This works, even if the controls are anchored top, left and right.
Works at least for Visual Studio 2013 and 2015.
This is one you should live with. Even in VS2008 such things happen from time to time. It is mostly depends on form content (controls, positions, etc), and there is no option in VS to disable such behavior.
When you open your form in designer, vs runtime rebuilds visual appearance from code behind. And sometimes it made changes at this moment. Also when you are simply adding one control to form, designer fully rebuilds codebehind and resource files. This is well known issue, and seems that MS won't fix it, because they move in WPF direction.
So several points to simplify your life:
Move to VS2008, designer were more consistent, but still shuffle controls in .designer.cs file
Place your code in one of the source repositories, so if you accidentally saved such form, you can restore it from repositary.
Setting the form Min and Max size settings to the current size was a good work around for me. This prevented VS from resizing it.
I had a trivial form with few controls on it, where the OK and Cancel at the bottom were being shifted up as soon as the form was opened in the VS2013 designer. The same behaviour was observed in VS2015.
The accepted answer here of DPI did not solve the issue for me, nor were there any issues on the size of the form/padding/margins.
Removing the controls that are shifted and adding them back into the form solved the problem for me, as suggested by ptutt here:
Visual Studio designer moving controls and adding grid columns when form is opened
While I appreciate ryantum's suggestion and links of using docking [with panels], as also referred to in the link above with Roland's blog post here https://weblogs.asp.net/rweigelt/28984, with something so trivial I'd rather just make it go away with removing/adding back in.
I found locking the controls from the format menu was a simple and effective solution. VS2013
I had this problem with VS 2015.
I used dock panels with the controls that moved unexpectedly as their childs.
By default the controls will be aligned to the left, but you can change the orientation.
My buttons stopped moving.
I had this issue, too. Every time I opened the designer, every box with anchor "right" was moved about 20 Pixels to the left. Additionally, the bottom of every box with anchor "left" was about 200 pixels outside the form.
This form has many controls and should not shrink on smaller displays, so it was set to autoscroll, the form itself was smaller in the designer than the shown minimum size (historically...). I just set the size to the minimum size so that no scroll bars appeared in the designer and the anchors worked as expected without screwing up the postitions.
I read the first post from ryantm's answer which led me to the solution. Apparently it has something to do with the order .Net executes events such as setting the size of a form.

Categories