How can you create clone objects using a loop so that you can access each of them individually? For example 10 buttons:
for ($i = 1; $i -le 10; $i++) {
$Obj = New-Object System.Windows.Forms.Button
$Obj.Left = 30 * $i + 10
$Obj.Top = 10
$Obj.Width = 30
$Obj.Height = 30
$Form.Controls.Add($Disk)
}
And then make assignments in the script, let's say the text:
$Obj1.Text = 'One'
$Obj2.Text = 'Two'
...
$Obj10.Text = 'Ten'
Somehow, in the loop, it is necessary to specify the names of the objects $Obj1, $Obj2...$Obj10. Perhaps using this:
$Obj = New-Variable -Name ('Obj' + [string]$i)
But my knowledge is not so good to do it right away. Thanks for answers.
$Obj[$Index].Text?