简体   繁体   中英

C# - Layout problem on Windows XP professional

I am developing a C# application with .NET Framework 2.0.

The problem is, that on my client's PC, the controls get expanded, layout changes (positions of the controls gets changed), sometimes buttons get missed entirely. It happens even on Forms with 2-3 TextBoxes, 2-3 Buttons and some Labels. I tried a lot of investigations. I tried to show a message in the form's resize event. But it doesn't get called. After digging a bit more, it seemed that in Designer.cs file even though ResumeLayout (false) is being called for the form, but this causes the the expansion/disposition of the controls.

My Client is using Windows XP professional on his Dell laptop. He is able to reproduce the issue on other laptops with Windows XP professional. But not in other OSes (like Windows XP Home or Windows Vista). In my desktop with Windows XP professional, it is not reproducible.

How can this issue be resolved?

Are you sure it has anything to do with the OS? It sounds more like a dpi issue. 'Normal' is 96 dpi. If the form was designed at 96 dpi, it would probably look different at a different setting.

See this article for how to check/change the dpi settings in XP.

Edit: I forgot to mention that you can use the TableLayoutPanel Control to layout your form. Using the auto-sizing capabilities will help keep things looking 'normal' at any dpi setting.

It's probably due to the DPI setting in Windows XP.

If you're using the standard (96) DPI setting, but they're setup using a alternative one (ie: 120), it often will mess up layouts of controls.

The "right" way to handle this is to try to automatically build your layouts using layout elements that can resize as needed. This is difficult in Windows Forms (and one of the things WPF fixes).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM