1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
$buttons_functionslist=@( "1" "2" "3" "4" "5" "6" "7" "8" "9" ) $buttons_functionbuttoncount = $buttons_functionslist.count $loop,$loop2 = 0 #Formulario $Form = New-Object System.Windows.Forms.Form $Form.Text="Formulario" $Form.Size=New-Object System.Drawing.Size(100,300) $Form.StartPosition="CenterScreen" $valor = 0 while($loop -lt $buttons_functionbuttoncount) { $thisbutton = New-Object System.Windows.Forms.Button [string]$thisbuttonname = $buttons_functionslist[$loop] #$thisbutton.Text = $thisbuttonname $thisbutton.size = New-Object System.Drawing.Size(30,30) if($loop%3 -eq 0) { $valor += 30 $thisbutton.Location = New-Object System.Drawing.Size(15,$valor) $loop2 = 1 } else { $thisbutton.Location = New-Object System.Drawing.Size((($loop2*30)+15),$valor) $loop2 += 1 } $thisbutton.Add_Click({ if($this.text -eq "0") { $this.text = "X" } else { $this.text = "0" } }) $Form.Controls.Add($thisbutton) $loop += 1 } $Form.ShowDialog() |