Size box not taking entered values

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Post Reply
User avatar
harringg
Posts: 11
Last visit: Fri Jul 23, 2021 6:51 am

Size box not taking entered values

Post by harringg »

Product: PowerShell Studio 2021 (64 Bit)
Build: v5.8.191
OS: Windows 10 Enterprise (64 Bit)
Build: v10.0.19042.0

What would cause an element to not accept size values?
Drag Label element to Form Designer, use default settings

Label
Size>Width, enter a value, press Enter, it reverts to the previous value
SizeControls.gif
SizeControls.gif (69.18 KiB) Viewed 604 times

jvierra
Posts: 14866
Last visit: Wed Jul 21, 2021 2:13 am
Answers: 12
Has voted: 3 times
Been upvoted: 10 times

Re: Size box not taking entered values

Post by jvierra »

Control is set to autosize? Not enough info to know the exact answer.

User avatar
harringg
Posts: 11
Last visit: Fri Jul 23, 2021 6:51 am

Re: Size box not taking entered values-Resolved

Post by harringg »

Yes, that was it. Autosize = $true

I'm coming to Sapien (pro grade) from Poshgui (consumer grade) and it's not as advanced with validation (it's good for the basics).

Since Sapien doesn't allow import from an existing WinForm.ps1, I'm hand coding from my legacy projects, and was trying to a like for like on my code. Only to realize that the actual text is clearly longer than 25 wide, but Poshgui didn't validate that like Sapien does.

Trying to match this in my PSS project, but realize in PSS it's too "smart" to let me add a smaller size .width box, when Auto is true, if the actual text is larger.

In short, I now understand what's going on. Thanks.

Code: Select all

$Labelworkstation                    = New-Object system.Windows.Forms.Label
$Labelworkstation.text               = "Enter Workstation Name (partial names accepted):"
$Labelworkstation.AutoSize           = $true
$Labelworkstation.width              = 25
$Labelworkstation.height             = 10
$Labelworkstation.location           = New-Object System.Drawing.Point(10,10)
$Labelworkstation.Font               = 'Microsoft Sans Serif,10'
$Labelworkstation.ForeColor = "#ffffff"
$Labelworkstation.BackColor = "Transparent"

jvierra
Posts: 14866
Last visit: Wed Jul 21, 2021 2:13 am
Answers: 12
Has voted: 3 times
Been upvoted: 10 times

Re: Size box not taking entered values

Post by jvierra »

It is good that that was the issue as there could be other causes.

Your issues have nothing to do with Sapien. PSS is just a frame that uses Microsoft Net tools to design forms. Sapien inforces nothing and doesn't alter any default behaviors. Everything you see is Microsoft WinForms. The issue is that most non-programmers do not learn WinForms but just copy code and guess at how to code. If you look up the control in issue on MS you would have seen the answer. All control docs can be accessed via the context menu for the control in the toolbox.

Learning to use the tool is critical so read all of the online PSS documenation and get completely oriented as it will save you tons of time and allow you to build, convert or alter forms quickly and easily.

PowerGUI was never a tool that was meant for developers. It was a simple toool used to assist basic techs to add simple dialogs to scripts.

Post Reply