Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why does Visual Studio modify "Windows Form Designer generated code" on designer open?

When working w/ a WinForm project in VS.NET 2015, our team has noticed that the mere act of opening a .VB form in the designer view (default action when double-clicking the file in Solution Explorer) will cause VS to modify many object properties in the "Windows Form Designer generated code" section of the actual .VB code-behind. It seems to be limited to the .Size and .Location properties for sometimes dozens or more of UI objects, always changing their X,Y coords just slightly.

Mind you we don't perform any action to drive this -- simply open the file (obtained from source-control and residing in the local solution/project) in VS.NET's form designer by double-clicking the file in Solution Explorer, and bam -- it has the "unsaved" asterisk and if you save it and compare to source control version you can see the modifications already made.

I couldn't find much on this. Is this a known behavior? Any idea why it does this? Kind of reminds me of the old days w/ MS FrontPage's designer view, and even the early days of ASP.NET in VS which would apply some HTML changes if you opened a WebForm in designer view, until they gave the option to disable that on a later release.

thanks for any input.

UPDATE: this appears to be continuing even with myself as the only editor of the .VB form in designer. various form elements are shifting their position very slightly. Here's a diff screenshot between my last check in and today, and I know I'm the only one editing:

enter image description here

...there are many like that. Always these two properties, always just a few pixels difference.

like image 630
mdelvecchio Avatar asked Jun 29 '16 17:06

mdelvecchio


People also ask

What is Windows Form Designer generated code?

The Windows Form Designer generated code is code that is generated when you use the Design view of your project where you see the user interface of your program.

What is the purpose of form design window?

The Windows Forms Designer shows the designer surface for the DemoCalculator control. In this view, you can graphically design the appearance of the control by selecting controls and components from Toolbox and placing them on the designer surface.

How do I enable Windows Form Designer on .NET core in Visual Studio 2019?

To enable it, please turn on following option: Tools -> Options -> Preview Features -> 'Use the Preview of Windows Forms designer for . NET Core apps' and restart Visual Studio. Note that this option is available only in Visual Studio Preview versions at present and not in release versions.


1 Answers

I don't have an specific answer for this, but since this drove us crazy a bit a few months ago with my team, while working on a WinForms project, I am glad to share my experience!

Every time someone opened any form on VS2015, it would ask other people who has the same solution open at that time to reload the code. We first thought the third party controls (at that time it was both DevExpress and Infragistics) we are using were re-generated on designed initialization - because they tend to do that a lot but then we realised this kept happening on forms that only contains .NET controls.

Now the funny part. This only happened to us on VS2015. We were using VS2013 before, without this annoying problem.

Long story short, then we realized the screens we are using have different DPIs, just like Cody Gray said. I am not absolutely sure if this was the reason, but since we started using TFS, obviously we don't have the problem anymore... Hope this helps somehow lol.

like image 135
Michael Wayne Avatar answered Oct 21 '22 14:10

Michael Wayne