SftTree/NET 3.0 supports per-monitor DPI awareness (Per-Monitor v2). In a per-monitor aware application, the tree control adapts when its window moves to a monitor with a different scale factor: scroll bars, the splitter bar, tooltips and other elements the control draws itself are sized for the monitor's DPI, and fonts defined for individual parts and for headers, footers and row headers are scaled like the control's own font.
A Windows Forms application becomes per-monitor aware with this setting in its app.config file (.NET Framework 4.7 or later), together with Windows 10 compatibility in its application manifest:
<System.Windows.Forms.ApplicationConfigurationSection> <add key="DpiAwareness" value="PerMonitorV2" /> </System.Windows.Forms.ApplicationConfigurationSection>
A .NET 10 application becomes per-monitor aware by calling Application.SetHighDpiMode(HighDpiMode.PerMonitorV2) before it creates its first window.
The control's DeviceDpi property returns the DPI of the monitor showing the control, and the DpiChangedAfterParent event occurs when it changes. Both are inherited from the Control class. The SftTree/NET samples are per-monitor aware.
Two properties define how images and pixel values defined by the application follow the DPI. Both default to AsIs, which keeps the behavior of earlier versions:
| Property | Stretch |
|---|---|
| ImageScaling | All images are treated as designed for 96 DPI and are scaled with the display DPI: images in cells, item images, expand/collapse buttons, check boxes, radio buttons, sort indicators and other built-in images. |
| PixelScaling | Pixel values are treated as values for 96 DPI and are scaled with the display DPI: column widths and their minimum and maximum, the row header width, indentation, item heights, margins and gaps (Dimensions, Headers, Footers and RowHeaders), the splitter position and its limits, the horizontal extent and offset, and the sizes of image, gap and progress bar parts. |
With PixelScaling set to Stretch, properties return the values as they were set, so a form designed at one DPI looks the same at any DPI. Values the control calculates, such as the result of GetOptimalWidth or a column width changed by the user, are converted to 96-DPI values before they are stored. GetDimension and the hit-testing methods (ItemFromPoint, CellFromPoint, ColumnFromPoint) always use pixels on the display.
Applications that are only DPI aware for the primary monitor (System DPI aware) get the same scaling at the system DPI.