Form position size...

Ask your Windows PowerShell-related questions, including questions on cmdlet development!
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.
Locked
User avatar
JMS_PT
Posts: 73
Joined: Wed Dec 09, 2015 4:10 am

Form position size...

Post by JMS_PT » Sun Jan 03, 2016 7:35 am

I need to to set the Form`s position, size, etc.. when it loads
So far I can only get WindowState working using the $Form1_Shown = {} event, all others fail...

$Form1.Size.Width = $varFrmMSizeWidth
$Form1.Size.Height = $varFrmMSizeHeight
$Form1.Location.X = $varFrmMLocationX
$Form1.Location.Y = $varFrmMLocationY
$Form1.StartPosition = $varFrmMStartPosition
$Form1.WindowState = $varFrmMWindowState

These global variables are populated from an XML file when the form loads
Besides "WindowState" how to get all others working?

User avatar
JMS_PT
Posts: 73
Joined: Wed Dec 09, 2015 4:10 am

Re: Form position size...

Post by JMS_PT » Sun Jan 03, 2016 7:42 am

Ok, found the solution here
viewtopic.php?t=1751

$Form1.Size = New-Object System.Drawing.Size ($varFrmMSizeWidth, $varFrmMSizeHeight)
$Form1.Location = New-Object System.Drawing.Point($varFrmMLocationX, $varFrmMLocationY)

Thank you.

User avatar
jvierra
Posts: 11857
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Form position size...

Post by jvierra » Sun Jan 03, 2016 8:04 am

If you are using XML then you want to use strings to set values ... like this:

$form1.Size='400,600'
$form1.Location='50,100'

Also

$form1.StartPosition='CenterScreen'

User avatar
JMS_PT
Posts: 73
Joined: Wed Dec 09, 2015 4:10 am

Re: Form position size...

Post by JMS_PT » Mon Jan 11, 2016 7:53 am

Thank you.

Locked