Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[minor bug] Label too big or on wrong position #2685

Closed
theuserbl opened this issue Jan 11, 2020 · 1 comment
Closed

[minor bug] Label too big or on wrong position #2685

theuserbl opened this issue Jan 11, 2020 · 1 comment

Comments

@theuserbl
Copy link

@theuserbl theuserbl commented Jan 11, 2020

The Label is too big or on an other position, then on .net Framework.
It overlaps partly the TextBox in the following program.

Here a screenshot:

WinForms

The program for PowerShell ( taken from https://www.script-example.com/Powershell-GUI )

Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing
$window = New-Object System.Windows.Forms.Form
$window.Width = 1000
$window.Height = 800
$Label = New-Object System.Windows.Forms.Label
$Label.Location = New-Object System.Drawing.Size(10,10)
$Label.Text = "Text im Fenster"
$Label.AutoSize = $True
$window.Controls.Add($Label)
$windowTextBox = New-Object System.Windows.Forms.TextBox
$windowTextBox.Location = New-Object System.Drawing.Size(10,30)
$windowTextBox.Size = New-Object System.Drawing.Size(500,500)
$window.Controls.Add($windowTextBox)
 
  $windowButton = New-Object System.Windows.Forms.Button
  $windowButton.Location = New-Object System.Drawing.Size(10,60)
  $windowButton.Size = New-Object System.Drawing.Size(50,50)
  $windowButton.Text = "OK"
 
$window.Controls.Add($windowButton)

[void]$window.ShowDialog()

and in C#

using System.Windows.Forms;
using System.Drawing;

public class tst {
  public static void Main() {
    var window = new Form();
    window.Width = 1000;
    window.Height = 800;
    var Label = new Label();
    Label.Location = new Point(10,10);
    Label.Text = "Text im Fenster";
    Label.AutoSize = true;
    window.Controls.Add(Label);
    var windowTextBox = new TextBox();
    windowTextBox.Location = new Point(10,30);
    windowTextBox.Size = new Size(500,500);
    window.Controls.Add(windowTextBox);
 
    var windowButton = new Button();
    windowButton.Location = new Point(10,60);
    windowButton.Size = new Size(50,50);
    windowButton.Text = "OK";
 
    window.Controls.Add(windowButton);
    Application.EnableVisualStyles();   // optional
    window.ShowDialog();
  }
}

I have tested the program on .net Framework v4.0.30319 on Win8.1 with and without Visual Styles as program and as PowerShell Skript on Windows PowerShell 4.0 on one side. And on .net Core 3.1 with and without Visual Styles and on PowerShell 7.0.0-rc-1 on the other side.

@weltkante

This comment has been minimized.

Copy link
Contributor

@weltkante weltkante commented Jan 11, 2020

The position should not differ since you are using absolute coordinates but you have the label on autosize so its size may differ. The default font is different in .NET Core and Desktop so you must make sure you are giving enough space for the larger font of both systems when you work with absolute coordinates. See https://docs.microsoft.com/en-us/dotnet/core/compatibility/framework-core#controldefaultfont-changed-to-segoe-ui-9pt for the font change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.