Hi,
If I've scripted the size of an object in the MainForm.psf file, in the $frmInstApps_Load event (for example, $myButton.Location.X = 15), will that override whatever setting might be entered for that property in the Properties panel? If not, how do I make sure that it does? Also, is putting that code in the MainForm.psf file > $frmInstApps_Load event the right place to put it?
Thanks,
Scott
Setting Properties in Panel vs. Script
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.
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.
-
- Posts: 14
- Last visit: Thu Feb 22, 2024 7:41 am
Re: Setting Properties in Panel vs. Script
It should work if you are putting the code in the load event, but that is not how you resize a control. The example provided changes the location of the button rather than resizing. To resize, it would look something like the following:
Setting this in the load event will override the value set from the Properties panel. As I don't know what you are attempting to accomplish, I cannot say it is the right place. Unless you are changing the value multiple times in your script, setting it once from the Properties panel is the best choice.
For better understanding how psf files generate a ps1 file, the following article may be helpful:
https://www.sapien.com/blog/2022/01/04/ ... ll-studio/
- $myButton.Size = New-Object System.Drawing.Size(98, 33)
For better understanding how psf files generate a ps1 file, the following article may be helpful:
https://www.sapien.com/blog/2022/01/04/ ... ll-studio/
Brittney
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
-
- Posts: 14
- Last visit: Thu Feb 22, 2024 7:41 am
Re: Setting Properties in Panel vs. Script
Sorry, yes, I meant to type $myButton.Size, not $myButton.Location.X.
To be clear, if I wanted to set the left padding for that button, could I enter $myButton.Padding.Left = 15 ?
Scott
To be clear, if I wanted to set the left padding for that button, could I enter $myButton.Padding.Left = 15 ?
Scott
Re: Setting Properties in Panel vs. Script
Padding is a little different. You need to provide a value for all sides like so:
This would be generated for you if you used the Properties panel rather than attempting to set it under the form load event.
- $myButton.Padding = '0, 15, 0, 0'
Brittney
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
-
- Posts: 14
- Last visit: Thu Feb 22, 2024 7:41 am
Re: Setting Properties in Panel vs. Script
OK, so is it possible to set, for example, just the Y location value of an element? If so, how would you do that?
Thanks
Thanks
Re: Setting Properties in Panel vs. Script
[Topic was moved to PowerShell GUIs forum by moderator]
Brittney
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
Re: Setting Properties in Panel vs. Script
I recommend setting values in the Properties panel then exporting the script to ps1 to give you an idea of how they are written.
Brittney
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.