Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Creating Radio buttons in a for loop

$
0
0

I have a script I need to complete that makes radio buttons for each item I've specified in an XML file.  When I try to create a radio button within a for loop, I get only one radio button variable called object instead of the multiple buttons (Button1, Button2, Button3)I am expecting.  The script DOES produce the radio buttons on the gui but they are not addressable. What is the correct way to create objects dynamically?

$rad = 0

$Radiobutton = @('$Radiobutton1','$Radiobutton2','$Radiobutton3')

foreach($object in $RadioButton)

{

$object = New-Object System.Windows.Forms.RadioButton

$object.Location = New-Object System.Drawing.Size($RadiobuttonXStart,$RadiobuttonYStart)

$object.Size = New-Object System.Drawing.Size($RadiobuttonX,$RadiobuttonY)

$object.Text = $buttonName

$objForm.Controls.Add($object)

$Rad++

}


Viewing all articles
Browse latest Browse all 6937

Trending Articles