Win Form Design Change as the screen resolution Change - c#

We are developing a WinForm application. We have different resolution monitors when designing win form on low resolution and viewing on high resolution, the positions are changed and they appear merged. Could anyone suggest how to resolve this issue. Thanks in advance
We are using VS2102 For development. And Framework is 4.0

If you are starting with development on Windows Desktop you can also explore on WPF, it has a higher initial learning curve than WinForms, but is far more extensible.
If you are still going for WinForms, take a look at dynamically controlling the sizing from this answer https://stackoverflow.com/a/6575311/5788393

Related

Windows custom scaling break the Winform app look

I am developing Windows form application using C#. I found that this application is scaled correctly if I used the default scaling offered by Windows 10 (100%, 125%, 150%). But if I used the custom scaling like 110%, 115%, 135%,... the application gone bad. You can see the picture bellow (left is 125% and right is 135%).
What I have tried so far: enabled dpi awareness, set AutoResizeMode to none/dpi/font, but didn't work.
Is there anyway I can prevent the Windows from breaking my application if the custom scaling is enabled? I know the Winform is old and also maybe its the Windows problem itself, but any advices will be appreciated.

alignment is not getting proper in different resolution

i am working on visual studio 2010.
i created my master form windows state is Maximized
my system resolution is 1366X768 ,,in one button click i am calling 5 forms together into my master form.. but in my system everything getting correct..
but i installed the same application in my client system,,that system resolution is 1024X768
but here my alignment is not getting proper..now my image is getting like this:
so how i can fit my windows form application in all resolution,,if any one know please help me to find out
You basically have two options:
1) Follow Microsoft's instruction on implementing auotscaling for Windows forms applications. (See http://msdn.microsoft.com/en-us/library/ms229605(v=vs.110).aspx)
2) Write your own code to scale the form based on resolution.
============================
Other factors to keep in mind.
If you app is translatable that can affect scaling
A user changing the Windows default font size can have the same affect.
Hope this helps.

Displaced controls in windows forms .net framework

I have a strange problem. I have designed a windows form application in c# and .net framework 3.5. In the runtime, the form and its controls are fine in all the computers except my laptop, where the controls are not in the correct positions.
If I design the form from scratch on my laptop with correct positioning it will result in an invalid shape for other computers.
My efforts:
If I run the windows in Safe Mode the form size and control positions
are correct.
I have uninstalled the Video Driver and used default windows version but the problem still persists.
I used different frameworks like 2.0 and 4.0, and different Visual Studios versions and they all have the same problems.
Actually all the .net framework product from all the companies indicate the same issue.
My computer Settings:
Laptop 1557 Studio DELL
Graphic ATI Radeon HD 4500
When the text size is artificially increased to 125% text and controls that are rather closely placed will wrap around the form and push everything down/over. If this is something you intend to support, you'll simply have to redesign your form to handle the different enlargement levels you care to support and test those enlarged text modes in your app until you're satisfied with their appearance. It's not something you can strictly control, since increased text size is an accessibility feature.
I assume it is due to a screen resolution differences. I believe that the actual location of the controls is identical in both cases, in one the screen is "larger" and therefor your controls appear in a different position on the screen.
try Designing forms to work on different resolutions and aspect ratios on Windows CE
Another thing you can (and should) do is work with WPF, which is the new way to build user interfaces for windows.
I've found a workaround just now.
In the display settings of Windows 7 I have changed the Text size from 125% to 100%. Everything is smaller but in accurate positions and sizes.
Still wondering how it works!!

What to do with a winforms app that looks poor with medium/large fonts enabled on windows 7?

I have a windows forms app built with .NET 3.5 and a relatively old version of Infragistics controls. It turns out some of the forms/controls look quite poor when viewed in Windows7 and Medium or Large Fonts. What are my options to resolve this? I have some tens of forms and would like a short-term solution rather than a rewrite, as the app will be migrated to WPF or Silverlight in the medium term.
Is there a switch I can 'turn off' medium/large fonts for the app as an immediate fix?
What general principles need to be followed for winforms apps to render nicely with medium/large fonts turned on?
So far the main things I've found I needed to do are:
Change forms/controls so AutoScaleMode is set to Font
Change any forms with programmatic resizing so they're dependent on other controls' size or position, rather than hard-coded numbers that are right if fonts are set to normal size.
Other than that things mostly work as desired. Mostly. Still the odd odd thing to track down.
+1 on the AutoScaleMode suggestion.
I redesigned all the forms into TableLayoutPanels (it took ages) and got set all my Labels to AutoResize = True. TableLayouts take most of the pain away. Scaling and alignment are a breeze, although they are quite slow compared to say WPF.

What is the easiest way to upgrade a large C# winforms app to WPF

I work on a large C# application (approximately 450,000 lines of code), we constantly have problems with desktop heap and GDI handle leaks. WPF solves these issues, but I don't know what is the best way to upgrade (I expect this is going to take a long time). The application has only a few forms but these can contain many different sets of user-controls which are determined programatically.
This is an internal company app so our release cycles are very short (typically 3 week release cycle).
Is there some gradual upgrade path or do we have to take the hit in one massive effort?
You can start by creating a WPF host.
Then you can use the <WindowsFormHost/> control to host your current application. Then, I suggest creating a library of your new controls in WPF. One at a time, you can create the controls (I suggest making them custom controls, not usercontrols). Within the style for each control, you can start with using the <ElementHost/> control to include the "old" windows forms control. Then you can take your time to refactor and recreate each control as complete WPF.
I think it will still take an initial effort to create your control wrappers and design a WPF host for the application. I am not sure the size of the application and or the complexity of the user controls, so I'm not sure how much effort that would be for you. Relatively speaking, it is significantly less effort and much faster to get you application up and running in WPF this way.
I wouldn't just do that and forget about it though, as you may run into issues with controls overlaying each other (Windows forms does not play well with WPF, especially with transparencies and other visuals)
Please update us on the status of this project, or provide more technical information if you would like more specific guidance. Thanks :)
Do you use a lot of User controls for the pieces? WPF can host winform controls, so you could piecewise bring in parts into the main form.
WPF allows you to embed windows forms user controls into a WPF application, which may help you make the transition in smaller steps.
Take a look at the WindowsFormsHost class in the WPF documentation.
I assume that you are not just looing for an ElementHost to put your vast Winforms app. That is anyway not a real porting to WPF.
Consider the answers on this Thread What are the bigger hurdles to overcome migrating from Winforms to WPF?, It will be very helpfull.
There is a very interesting white paper on migrating a .NET 2.0 winform application toward WPF, see Evolving toward a .NET 3.5 application
Paper abstract:
In this paper, I’m going to outline some of the thought processes, decisions and issues we had to face when evolving a Microsoft .NET application from 1.x/2.x to 3.x. I’ll look at how we helped our client to adopt the new technology, and yet still maintained a release schedule acceptable to the business.

Categories