Skip to content

Size of Form and controls is bigger in WinForms .NET Core app compared to WinForms .NET Framework app #1948

Closed

Description

@bairog
  • .NET Core Version: v3.0.0-rc1
  • Have you experienced this same bug with .NET Framework?: No

Problem description:

  1. Using Visual Studio 2019 16.3 Preview 4 create a WinForms .NET Core app and a WinForms
    .NET Framework app, which have same designer code with some controls added.
    WinFormsFrameworkApp.zip
    WinFormsCoreApp.zip

  2. Build and run these 2 apps, and compare size of forms and controls

Actual behavior:
Size of Form and controls is bigger in WinForms .NET Core app compared to WinForms .NET Framework app (for example Form is 1178x799 pixels on .NET Core 3.0 and 1010x697 pixels on .NET Framework 4.8)

Expected behavior:
They should have same size (pixel by pixel identical).

Activity

  1. changed the title [-]Size of Form and controls are bigger in WinForms .NET Core app compared to WinForms .NET Framework app[/-] [+]Size of Form and controls is bigger in WinForms .NET Core app compared to WinForms .NET Framework app[/+] on Sep 20, 2019
  2. bairog commented on Sep 20, 2019

    @bairog
    Author

    In all my form controls I don't use Segoe UI 9pt, I use Calibri 12pt.
    Why my forms are not pixel by pixel identical in that case?

  3. bairog commented on Sep 23, 2019

    @bairog
    Author

    Let me clarify - for example in both projects:

    1. Form size in designer is set to 1028x706 (font is Calibri 12pt)
    2. Button size in designer is set to 70x28 (font is Calibri 12pt)
      .NET Framework 4.8 app respects that sizes, while .NET Core 3 app is bigger than that values..
  4. RussKie commented on Sep 24, 2019

    @RussKie
    Contributor

    I believe the result is due to this line:

    this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);

    If you comment it out, it renders the form in the same size.

    Here's the relevant info: https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.containercontrol.autoscaledimensions?redirectedfrom=MSDN&view=netframework-4.8#remarks

    @OliaG this may trip a few people, perhaps we need to highlight this somehow.
    /cc: @merriemcgaw

  5. added
    area-HDPI-SA
    area-VSDesigner
    on Dec 11, 2019
  6. ghost locked as resolved and limited conversation to collaborators on Feb 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-HDPI-SAarea-VSDesigner

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions