Powershell RadioButton Nr. zwei wird nicht angezeigt?
Hallo Zusammen In Meinem Powershellscript wird mein zweiter RadioButton nicht angezeigt wieso?
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") $objForm = New-Object System.Windows.Forms.Form $objForm.Size = New-Object System.Drawing.Size(800,700)
$RadioButton1 = New-Object System.Windows.Forms.RadioButton $RadioButton1.Location = New-Object System.Drawing.Point(15, 15) $RadioButton1.Size = New-Object System.Drawing.Size(90, 90) $RadioButton1.Checked = $True $RadioButton1.Text = "Inkrementell"
$RadioButton3 = New-Object System.Drawing.RadioButton $RadioButton3.Location = New-Object System.Drawing.Point(15, 50) $RadioButton3.Size = New-Object System.Drawing.Size(90, 90) $RadioButton3.Checked = $false $RadioButton3.Text = "VollBackup"
$GroupRadioBox = New-Object System.Windows.Forms.GroupBox $GroupRadioBox.Location = New-Object System.Drawing.Size(200, 200) $GroupRadioBox.Size = New-object System.Drawing.Size(300, 300) $GroupRadioBox.Controls.Add($RadioButton1) $GroupRadioBox.Controls.Add($RadioButton3) $objForm.Controls.Add($GroupRadioBox)
[void] $objForm.ShowDialog()
1 Antwort
1) Diese Zeile ist falsch:
$RadioButton3 = New-Object System.Drawing.RadioButton
Sie muss so lauten:
$RadioButton3 = New-Object System.Windows.Forms.RadioButton
2) Dein erster Radiobutton hat eine Höhe von 90px und beginnt bei einem Top von 15px. Das zusammengerechnet ergibt, dass seine Höhe bei 105px liegt. Dabei verdeckt er den Button, der sich nur 35px weiter tiefer befindet.
Verschiebe oder ändere also die Größen.
Im Übrigen kannst du Größenangaben vereinfachen:
$RadioButton1.Location = '15,15'
(gilt z.B. bei Location und Size)
Sowie das Hinzufügen von Komponenten zu einer Gruppe:
$GroupRadioBox.Controls.AddRange(@($Radiobutton1, $RadioButton3))