dotnet / winforms

Windows Forms is a .NET UI framework for building Windows desktop applications.
MIT License
4.29k stars 957 forks source link

The TreeView incorrectly scale on the high DPI devices #9881

Open hmisaki opened 10 months ago

hmisaki commented 10 months ago

.NET version

.NET 6.0

Did it work in .NET Framework?

Yes

Did it work in any of the earlier releases of .NET Core or .NET 5+?

No

Issue description

The item text is cut inside the TreeView in high DPI. See shortcut: image It works in .net framework 4.7 : (change the from net6.0-windows to net47) image

The test code: TreeViewSample.zip

Steps to reproduce

  1. Create a VB form App(net 6.0) and place a TreeView. Fill in some content, for example, the paths under "C:\"
  2. build the project
  3. Set the DPI to 225%
  4. Run the app
dreddy-work commented 9 months ago

@Olina-Zhang, can you check this in the latest version and see if this is an issue only for VB?

Philip-Wang01 commented 9 months ago

@dreddy-work Verified this on .NET 8.0 latest build: 8.0.100-rc.2.23469.4,this issue may be a problem caused by the ItemHeight property of the TreeView.

  1. When adding a TreeView control at 225% DPI, its ItemHeight value defaults to 40, and the item text displays without problems when running the project.
  2. However, in the project provided by the customer, the ItemHeight is set to 16, and the item text does not scale well at runtime.
  3. Also, this problem can be reproduced in C# projects.

https://github.com/dotnet/winforms/assets/86937911/e3c72e8f-38a0-41a2-a5a7-2a8ec9a7909d