Programmatically Edit Element Property

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 1 year and 4 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Scott Rosenbloom
Posts: 14
Last visit: Thu Feb 22, 2024 7:41 am

Programmatically Edit Element Property

Post by Scott Rosenbloom »

Hey All,

I'm looking to center a button (called "btnSNCC") horizontally within a form (called "frmSN"). I know the formula would be "($frmSN.Width - $btnSNCC.Width)/2". I don't seem to be able to enter that within the Size > X field, so where would I put that code?

Thanks,
Scott
User avatar
brittneyr
Site Admin
Posts: 1655
Last visit: Thu Mar 28, 2024 9:46 am
Answers: 39
Been upvoted: 30 times

Re: Programmatically Edit Element Property

Post by brittneyr »

Have you tried putting it in the form load event?
Brittney
SAPIEN Technologies, Inc.
Scott Rosenbloom
Posts: 14
Last visit: Thu Feb 22, 2024 7:41 am

Re: Programmatically Edit Element Property

Post by Scott Rosenbloom »

As in, within the "When form loads" event in MainForm.psf?
Scott
User avatar
brittneyr
Site Admin
Posts: 1655
Last visit: Thu Mar 28, 2024 9:46 am
Answers: 39
Been upvoted: 30 times

Re: Programmatically Edit Element Property

Post by brittneyr »

Yes, the form's load event:
SPS_FormLoadsEvent.png
SPS_FormLoadsEvent.png (103.83 KiB) Viewed 4720 times
Brittney
SAPIEN Technologies, Inc.
Scott Rosenbloom
Posts: 14
Last visit: Thu Feb 22, 2024 7:41 am

Re: Programmatically Edit Element Property

Post by Scott Rosenbloom »

Mine doesn't seem to have a "Load" property. See attached.
Scott
Attachments
2022-11-04_10-30-12.png
2022-11-04_10-30-12.png (30.16 KiB) Viewed 4695 times
User avatar
brittneyr
Site Admin
Posts: 1655
Last visit: Thu Mar 28, 2024 9:46 am
Answers: 39
Been upvoted: 30 times

Re: Programmatically Edit Element Property

Post by brittneyr »

Load is an event, not a property. It is the default event added when a form is created in PowerShell Studio. To view events, you need to switch to the event tab from the Property panel.

You may find the following articles helpful:
https://www.sapien.com/blog/2021/11/23/ ... ll-studio/
https://www.sapien.com/blog/2022/01/04/ ... ll-studio/
https://www.sapien.com/blog/2021/07/26/ ... ndle-them/
Brittney
SAPIEN Technologies, Inc.
This topic is 1 year and 4 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.