PowerShell Create Windows Form

#PowerShell Create Windows Form# Create Form ``` $Form = New-Object system.Windows.Forms.Form ``` Set From Title ``` $Form.Text = "Test form" ``` Set Form Size ``` $Form.Width = 450 $Form.Height = 400 ``` Set show Form ``` $Form.ShowDialog() ``` Add Label to Form ``` $lineLabel = New-Object system.Windows.Forms.Label ``` set label text ``` $lineLabel.Text = "" ``` set label size ``` $lineLabel.Width = 380 $lineLabel.Height = 40 ``` Add Text box to Form ``` $Text = New-Object System.Windows.Forms.TextBox ``` set Text box multiline if ``` $$false ``` Textbox can not entry multiline ``` $Text.Multiline = $false ``` if ``` $true ``` Textbox can entry multiline ``` $Text.Multiline = $True ``` set Textbox size ``` $Text.Width = 200 $Text.Height = 20 ``` Add Textbox, Label to Form ``` $Form.Controls.AddRange(@($Text,$LineLabel)) ``` Full Code : ``` #Create form $Form = New-Object system.Windows.Forms.Form $Form.Text = "Test form" $Form.Width = 450 $Form.Height = 400 #Create Label $lineLabel = New-Object system.Windows.Forms.Label lineLabel.Text = "TEST" $lineLabel.Width = 380 $lineLabel.Height = 40 #Create TextBox $Text = New-Object System.Windows.Forms.TextBox $Text.Multiline = $false $Text.Width = 200 $Text.Height = 20 #Add Textbox, Label to form $Form.Controls.AddRange(@($Text,$LineLabel)) #Form start $Form.ShowDialog() ```

留言

這個網誌中的熱門文章

Easy Triangle Calculator

Powershell transfert UPS Worldship address book to csv file for UPS web import

Swift Sprite Kit easy to create bullet