I am writing a GUI for our helpdesk, and everything is mostly great.
However, my dropdown boxes refuse to move left regardless of where I well them to go.
The function I wrote to create dropdown boxes:
Function Add-DropdownBox($DropdownBox,$DropDownHeight,$DropdownBoxLeft,$DropdownBoxTop,$DropdownBoxWidth,$DropdownBoxHeight,$FormObject) { $DropdownBox = New-Object System.Windows.Forms.ComboBox $DropdownBox.Location = New-Object System.Drawing.point($DropdownBoxLeft,$DropdownBoxTop) $DropdownBox.Size = New-Object System.Drawing.Size($DropdownBoxWidth,$DropdownBoxHeight) $DropDownBox.DropDownHeight = $DropDownHeight $FormObject.Controls.Add($DropdownBox) # $DropdownBox }
The command I use to create them in the script:
$FolderShareDropdown1 = Add-DropdownBox -DropdownBox $FolderShareDropdown1 -DropDownHeight 200 $DropdownBoxLeft $CheckBoxAlignCol1 -DropdownBoxTop ($CheckBoxAlignRow+($TextboxHeight*1)) -DropdownBoxWidth ($TextBoxWidth*1.9) -DropdownBoxHeight $Textboxheight -FormObject $FolderShares
This is all on one line in my script.
Everything other than the leftmost position works fine, i.e. height changes, width changes and so on, when I change the variables. Just not the left most position.
Other elements position themselves correctly based on the $CheckBoxAlignCol1 variable (TextBoxes/Checkboxes/Buttons), so the variable does “work”.
If I write out the full lines, for example:
$DropDownBox = New-Object System.Windows.Forms.ComboBox $DropDownBox.Location = New-Object System.Drawing.Size(200,50) $DropDownBox.Size = New-Object System.Drawing.Size(10,20) $DropDownBox.DropDownHeight = 200 $FolderShares.Controls.Add($DropDownBox)
Then the dropdown box is positioned correctly, so I really can’t see why the function doesn’t work.
Any ideas anyone?