I have a script that launches a windows form. The issue I have is that it displays differently in PowerShell Core versus Windows Powershell. My core version is 7.2.4. No flames for posting images, I don’t know any other way to portray my issue.
Launching the form via Windows Powershell I get this, which is what I want:
Via PS Core, I get this:
The relevant code is:
$Testing123ChkBox = New-Object System.Windows.Forms.CheckBox
$Testing123ChkBox.Width = 90
I should point out I get no errors running the script. If I increase the .Width property, it displays fine in Core, but I don’t want to have to provide logic to use different values for different versions of PS. I also played wth the .TextAlign property with no success. I have googled, but no joy there, at least not for me. Thanks in advance for any advice you can provide.
I admit that I don’t have any experiences with GUIs in PowerShell … I assume you don’t have to increase the width that much to get the expected result in PS Core, right? Does it mess up your layout that much in Windows PowerShell when you increase the width there as well? I mean there could be a value working for both versions.
Another option would be to limit the compatibility of your script to one version of PowerShell. Both versions will be around for the next years - so it wouldn’t be that much of a limit.
Thanks for the advice Olaf. Yes, I did play around with trying to find a happy medium as you suggest. The control I showed is just one of many on the form, so it will take some time. As an example, for the control shown, I only needed to change the Width to 92 to display properly. In that case, Windows PS looked fine as well so that is the approach I am going to take. Going to 95 messed up the control next to it in Windows PS. I sure would like to know the root cause though.
Sadly, the requirement is that this work in all PowerShell versions from 3 on.
Again, Thanks for your input Mr. Wizard
… sounds like you should give everything more room … think bigger!
Without actually having any insights I’d suspect that this could be caused by different rendering defaults for padding, border or margins of the different dot net versions if there actually is something like this.
Oh wow, I’m sorry for you.