Anchored DataGridViews not expanding as expected on installation on other computers

96 Views Asked by At

I'm working on an C# WinForms App in Visual Studio 2022.

Part of the application is a user control that has several nested SplitContainers which in turn contain either a DataGridView that is docked to fill the entire Panel (which seems to be working fine) or Label with a DataGridView below it, anchored to all sizes. The idea is to resize the DataGridView when the application is resized but keep the Label static and visible. While developing the application this worked as I expected, however when run on some of my coworkers computers it does not and leaves empty space at the bottom of the panel.

The application is published with the following configuration:

  • Target framework : net6.0-windows
  • Deployment mode : Self-contained
  • Target runtime: win-x86

User control in design:user control

When working: example1

When not working example2

As this has been showing up inconsistently across computers that it runs on I suspect that my issue is in how it is published or there is some setting I'm missing on the controls themselves. I can provide any additional information on request if I've missed something pertinent.

Update: I've added an app manifest to the project and added:

  <application xmlns="urn:schemas-microsoft-com:asm.v3">
    <windowsSettings>
      <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
      <dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2</dpiAwareness>
    </windowsSettings>
  </application>

After that didn't work I removed the manifest and updated the csproj file:

  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>net6.0-windows</TargetFramework>
    <Nullable>enable</Nullable>
    <UseWindowsForms>true</UseWindowsForms>
    <ImplicitUsings>enable</ImplicitUsings>
    <ApplicationHighDpiMode>PerMonitorV2</ApplicationHighDpiMode>
  </PropertyGroup>

Behavior remains the same.

0

There are 0 best solutions below