I can set form elements inside hashtable:
$Hash = @{}
$Hash.Main = New-Object System.Windows.Forms.Form
$Hash.Main.Left = 0
$Hash.Main.Top = 0
...
$Hash.Label = New-Object System.Windows.Forms.Label
$Hash.Label.Left = 0
$Hash.Label.Top = 0
...
$Hash.Panel = New-Object System.Windows.Forms.Panel
$Hash.Panel.Left = 0
$Hash.Panel.Top = 0
...
How can I write the same thing inside hashtable? I tried to make it as if it could be. And it works. But is this syntax correct?
$Hash = @{
Main = [System.Windows.Forms.Form] @{
Left = 0
Top = 0
...
}
Label = [System.Windows.Forms.Label] @{
Left = 0
Top = 0
...
}
Panel = [System.Windows.Forms.Panel] @{
Left = 0
Top = 0
...
}
}
Thank you
Yes, this syntax is correct:
Creating Objects from Hash Tables
Check the first condition (a constructor that has no parameters):
Check the latter condition (object properties must be public and settable):
Getting both above code snippets together is a trivial task…