Hallo zusammen,
Ich versuche eine GUI zu bauen, bei es mehrere Checkboxen gibt und wenn eine Checkbox angeklickt wird, soll dies den Content beeinflussen, der dann in Dropdowns verfügbar ist.
Ich scheitere nun daran, den Status der Checkbox dauerhaft zu "überwachen". Initial beim Start des Scripts habe ich den Status, wenn ich dann in der GUI die Checkbox anklicke, wird diese Veränderung nicht erkannt und ich habe noch keine Lösung gefunden, die ich zum laufen bekommen haben. Vll. kann mir ja jmd. erklären, wie man das macht.
Anbei noch der Code meiner GUI:
$header = "Mailadresse","Mandant", "Opt1","Opt2","Opt3","Opt4","Opt5" $kontakte = Import-Csv -Path 'XXXX\Kontakte.csv' -Header $header $Mandant = $kontakte.Mandant $Opt1 = $kontakte.Opt1 $Opt2 = $kontakte.Opt2 $Opt3 = $kontakte.Opt3 $Opt4 = $kontakte.Opt4 $Opt5 = $kontakte.Opt5 Add-Type -AssemblyName System.Windows.Forms [System.Windows.Forms.Application]::EnableVisualStyles() $Form = New-Object system.Windows.Forms.Form $Form.ClientSize = '800,400' $Form.text = "Form" $Form.TopMost = $false $CheckBox1 = New-Object system.Windows.Forms.CheckBox $CheckBox1.text = "Opt1" $CheckBox1.AutoSize = $false $CheckBox1.width = 100 $CheckBox1.height = 20 $CheckBox1.location = New-Object System.Drawing.Point(10,20) $CheckBox1.Font = 'Microsoft Sans Serif,10' $CheckBox2 = New-Object system.Windows.Forms.CheckBox $CheckBox2.text = "Opt2" $CheckBox2.AutoSize = $false $CheckBox2.width = 100 $CheckBox2.height = 20 $CheckBox2.location = New-Object System.Drawing.Point(110,20) $CheckBox2.Font = 'Microsoft Sans Serif,10' $CheckBox3 = New-Object system.Windows.Forms.CheckBox $CheckBox3.text = "Opt3" $CheckBox3.AutoSize = $false $CheckBox3.width = 100 $CheckBox3.height = 20 $CheckBox3.location = New-Object System.Drawing.Point(210,20) $CheckBox3.Font = 'Microsoft Sans Serif,10' $CheckBox4 = New-Object system.Windows.Forms.CheckBox $CheckBox4.text = "Opt4" $CheckBox4.AutoSize = $false $CheckBox4.width = 100 $CheckBox4.height = 20 $CheckBox4.location = New-Object System.Drawing.Point(310,20) $CheckBox4.Font = 'Microsoft Sans Serif,10' $CheckBox5 = New-Object system.Windows.Forms.CheckBox $CheckBox5.text = "Opt5" $CheckBox5.AutoSize = $false $CheckBox5.width = 100 $CheckBox5.height = 20 $CheckBox5.location = New-Object System.Drawing.Point(410,20) $CheckBox5.Font = 'Microsoft Sans Serif,10' $Filter1 = New-Object system.Windows.Forms.ComboBox $Filter1.text = "Filter1" $Filter1.width = 100 $Filter1.height = 20 $Filter1.location = New-Object System.Drawing.Point(8,120) $Filter1.Font = 'Microsoft Sans Serif,10' $Filter2 = New-Object system.Windows.Forms.ComboBox $Filter2.text = "Filter 2" $Filter2.width = 100 $Filter2.height = 20 $Filter2.location = New-Object System.Drawing.Point(119,120) $Filter2.Font = 'Microsoft Sans Serif,10' $Filter2.Items.AddRange($Opt1) $Filter3 = New-Object system.Windows.Forms.ComboBox $Filter3.text = "Filter3" $Filter3.width = 100 $Filter3.height = 20 $Filter3.location = New-Object System.Drawing.Point(230,120) $Filter3.Font = 'Microsoft Sans Serif,10' $Form.controls.AddRange(@($Filter1,$Filter2,$Filter3,$CheckBox1,$CheckBox2,$CheckBox3,$CheckBox4,$Checkbox5)) [void] $Form.ShowDialog()
Schon mal sorry, wenn das eigentlich total offensichtlich ist, aber mit GUIs hatte ich noch nichts zu tun.