2021/04/18 #リストボックスを表示

皆様おはようございます、

#猫でもできるPowerShell(備忘録)

#リストボックスを表示

 

<# 元ネタ
https://www.atmarkit.co.jp/ait/articles/0607/26/news118_3.html
#>
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing

$Form = New-Object System.Windows.Forms.Form
$Form.Size = "450,350"
$Form.StartPosition = "CenterScreen"
$Form.Text = "コントロール配置テスト"

$button = New-Object System.Windows.Forms.Button
$button.Location = New-Object System.Drawing.Point(180,10)
$button.Text = "押すな"
$button.add_Click({ $label.Text = "Get-Date -Format G"; $textbox.text = (iex $label.Text) })

$label = New-Object System.Windows.Forms.Label
$label.Location = New-Object System.Drawing.Point(10, 10)
$label.Size = New-Object System.Drawing.Size(180,20)
#$form.Controls.AddRange*1

$textBox = New-Object System.Windows.Forms.TextBox
$textBox.Location = New-Object System.Drawing.Point(10,60)
$textBox.Size = New-Object System.Drawing.Size(180,20)

$button_L = New-Object System.Windows.Forms.Button
$button_L.Location = New-Object System.Drawing.Point(10,90)
$button_L.Text = "戻る"
$button_L.add_Click({ $textbox.text = (get-date $textbox.text ).adddays(-1) })
$button_R = New-Object System.Windows.Forms.Button
$button_R.Location = New-Object System.Drawing.Point(90,90)
$button_R.Text = "進む"
$button_R.add_Click({ $textbox.text = (get-date $textbox.text ).adddays(+1) })


$grpBox = New-Object System.Windows.Forms.GroupBox
$grpBox.Location = New-Object System.Drawing.Point(10,140)
$grpBox.size = New-Object System.Drawing.Size(240,120)
$grpBox.text = "ラジオボタン"
$RadButton1 = New-Object System.Windows.Forms.RadioButton
$RadButton1.Location = New-Object System.Drawing.Point(10,20)
$RadButton1.size = New-Object System.Drawing.Size(80,30)
$RadButton1.Text = "Option1"
$RadButton1.Checked = $True
$RadButton2 = New-Object System.Windows.Forms.RadioButton
$RadButton2.Location = New-Object System.Drawing.Point(10,60)
$RadButton2.size = New-Object System.Drawing.Size(80,30)
$RadButton2.Text = "Option2"
$grpBox.Controls.AddRange(@($RadButton1,$RadButton2))

$ChkBox = New-Object System.Windows.Forms.CheckedListBox
$ChkBox.Location = "270,140"
$ChkBox.Size = "120,150"
$ChkBox.text = "ネタリスト"
$ChkBox.Items.AddRange*2


$form.Controls.AddRange(@($button,$label,$textBox,$button_L,$button_R,$grpBox,$ChkBox))
#[System.Windows.Forms.Application]::Run($form)
$Form.ShowDialog()

f:id:TPTPTb:20210419004833p:plain


だんだん節操無くなってきた・・

ではまた;

*1:$button, $label

*2:"大トロ","甘海老","炙りサーモン"