IngoB
-
Gesamte Inhalte
3 -
Registriert seit
-
Letzter Besuch
Beiträge erstellt von IngoB
-
-
On 12/18/2020 at 4:53 PM, BOfH_666 said:
Die Zuweisung ...
[string]$CADName = $DropDownBox.SelectedItem
... muss in den Block für die $Button.Add_Click Aktion. Du willst ja die Variable erst zuweisen, wenn Du den Button klickst, oder?
Ok danke....manchmal ist man offenbar einfach nur blind....
;)
-
Hallo
Ich bin noch bei den Basics von PS aber würde mir gern etwas kniffligeres anlernen.
Derzeit habe ich folgendes vor:
1. Eine GUI mit 2 Dropdowns
2. Dropdown 1 hat 3 Wahlmöglichkeiten
3. Die Auswahl von Dropdown 1 soll als Variable gespeichert werden
4. Die Variable soll dann verwendet werden um eines von 3 möglichen Textfiles zu wählen.
5. Der Inhalt des gewählten textfiles will ich an Dropdown 2 übergeben. (liste von Ordnern)
6. Beide selektionen werden dann als variable zum ausführen eines Bat files übergeben als $1 und $2
Natürlich habe ich ein wenig herumprobiert, komme aber auf keinen grünen zweig..
Ich schaffe es nicht die hürde zu nehmen das txt file pervariable zu finden!
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") $objForm = New-Object System.Windows.Forms.Form $objForm.BackgroundImage = $objImage $objForm.BackgroundImageLayout = "Center" $objForm.Text = "Selektion" $objForm.Size = New-Object System.Drawing.Size(400,300) #BOX1 $DropDownBox = New-Object System.Windows.Forms.ComboBox $DropDownBox.Location = New-Object System.Drawing.Size(10,40) $DropDownBox.Size = New-Object System.Drawing.Size(260,20) $DropDownBox.DropDownHeight = 200 [void] $DropDownBox.Items.Add('CATIA') [void] $DropDownBox.Items.Add('UGS') [void] $DropDownBox.Items.Add('PTC') $objForm.Controls.Add($DropDownBox) #$DropDownBox.Add_SelectedIndexChanged({ $CADName = $DropDownBox.SelectedItem; }) [string]$CADName = $DropDownBox.SelectedItem $Button = New-Object System.Windows.Forms.Button $Button.Location = New-Object System.Drawing.Size(10,60) $Button.Size = New-Object System.Drawing.Size(120,23) $Button.Text = "Select CAD" $objForm.Controls.Add($Button) #Add Button event $Button.Add_Click( { #BOX2 Write-Host "CADName=$($CADName)" $label2 = New-Object System.Windows.Forms.Label $label2.Location = New-Object System.Drawing.Point(10,90) $label2.Size = New-Object System.Drawing.Size(280,20) $label2.Text = 'Database Name' $objform.Controls.Add($label2) $DropDownBox2 = New-Object System.Windows.Forms.ComboBox $DropDownBox2.Location = New-Object System.Drawing.Size(10,110) $DropDownBox2.Size = New-Object System.Drawing.Size(260,20) $DropDownBox2.DropDownHeight = 200 $objForm.Controls.Add($DropDownBox2) $cadlist = Get-Content -Path "C:\Users\u22u47\Desktop\$($CADName).txt" foreach ($cad in $cadlist) { $DropDownBox2.Items.Add($cad) } }) $objForm.ShowDialog()
Powershell mehrfach Dropdown
in Windows Forum — Scripting
Geschrieben
Irgendwie stehe ich mit meinem Wissen komplett an...
Ich schaffe es nicht die beiden Variablen CADName und RELName auszugeben... habe mir ganz unten 2 zusätliche labels eingebaut um die selektion zu sehen..
Den CAD Name bekomme ich rein ins label 3 aber den REL Name nicht..
Ich bin mir sicher, dass mein aufbau komplett falsch ist.