Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
My Winform application is developed using visual studio 2013, and the operating system is windows 8. But when we run the application in windows 7 operating system, the GUI varies (not for all windows 7 machines).But it runs perfectly in windows 10 machines.

What I have tried:

I tried changing the height,padding etc. of controls in all the forms .but it does not work.
Posted
Updated 28-Apr-16 5:20am
Comments
Philippe Mori 28-Apr-16 12:23pm    
You don't say the difference you have.

You need to verify if the difference are caused by large font, user personnalization...

By the way WinForms might have some issues with high DPI.

Another to consider is scaling mode, font overwrite or color overwrite. And not all third party controls are created equals...

The key decision for you to make: are you going to ignore the users' choice of colors, fonts, styles, themes, etc.; or, are you going to "work with" that.

There's no "easy answer" for this one. To start with users with different screen-sizes with different resolutions (bit-depth) are going to show some variation in how things appear. You could go nuts trying to make your modern app look good on somebody's 640x480 screen. Unless you have no choice, I'd simply write-off thinking about design for XP, and someone using Aero: that's another problem area.

WinForms GDI+ rendering engine is something of a graphic-engine antique now; imho, for graphic rich apps with special effects, animations, fades, rotations, etc., better to head for WPF (or SilverLight ... is SilverLight still "alive").

You can try and make sure you use the Windows default settings for your machine as you develop; that means when the user runs it on their machine what they see will reflect the OS defaults, and the color/font/theme preferences they've set. ... That's the whole point of having those look-and-feel defaults, that's what Windows Style Guidelines are about.

If you are bound and determined that Control "x" in your app must appear with background color MidnightBlue, and forecolor GhostWhite: then set those explicitly. Let me repeat: when you don't the default: you must set to something other than the default.

And, the basic WinForm controls that are provided with Visual Studio: those are going to be rendered with some variations. For a given Control, look at (via the Property Browser) whether it offers various built-in styling options (Win 7, Office, etc.), and try and exploit that.

The best strategy if you are going to stick with the defaults is always have a machine to test on that's typical of what your users are using.

Those developers who want to have a custom look-and-feel get into "theming," which may include custom-shaped Forms, Controls, special gradient backgrounds, etc. There are numerous resources here and on the web for theming with a WinForm app. Just do a search.

But, if you really want theming, and vector-scaling of everything so the UI looks good at any size zoom: consider WPF, not WinForms. WPF also has a VisualStateManager facility I assume could be helpful (I haven't used it).

Then, there's "extreme theming" where the app offers its own run-time editor to set colors, fonts, sizes, etc., for every control and Form. Lots of work !

Finally, you could explore having your app read the OS Version when it starts up, and, in your code, use if/else, or switch/case, evaluation to make some visual change based on different versions. There a variety of ways you can do that: [^].

Here are some suggestions for you to research other aspects of .NET that may be relevant to your query:

1. UICulture

2. reading the DisplayRectangle and ClientRectangle properties of a WinForm on application start-up (or after the Form is shown). these properties, plus reading properties like FormBorderStyle, Padding, etc., can help you figure out the precise rectangle you can work with.

3. the AutoScaleMode, and AutoSizeMode properties can also be exploited. Definitely examine the differences between AutoScaleMode.Font and AutoScaleMode.dpi

And, all this is just the "warm-up."
 
Share this answer
 
Windows 8 has different [Metro] User Interface design. And Windows 7 and Vista has same UI appearance. Windows XP and other old Operating systems has its own UI which is different from another. So maintaining same appearance on different platforms is difficult. My suggestion is WPF, Check this discussion,
windows - Visual Studio C# desktop application GUI is rendering differently on different machine? - Stack Overflow[^]
 
Share this answer
 
Comments
BillWoodruff 28-Apr-16 10:31am    
WinForm apps do not run in Metro mode. A Winform can never be "on top" of a Metro App.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900