Good morning all,
I am working on a project for work and I have hit a snag.
My home version of Powershell is V5.0, Works is 3.0
I have a button that resets all data on the form.
It works at home but not at work. ![]()
Here is the code:
#Clear Button
$btnClear = New-Object System.Windows.Forms.Button
$btnClear.Location = New-Object System.Drawing.Size(($cboPriority.Left + $cboPriority.Width + 137),($cboPriority.Top - 3))
$btnClear.Size = New-Object System.Drawing.Size(140,30)
$btnClear.BackColor = "RED"
$btnClear.ForeColor = "White"
$btnClear.Text = "CLEAR MDS - ALL"
##Main Page##
#Clears All Text.
$btnClear.Add_Click{$txtLoginName.Clear()}
$btnClear.Add_Click{$txtBuilding.Clear()}
$btnClear.Add_Click{$txtFloor.Clear()}
$btnClear.Add_Click{$txtDesk.Clear()}
$btnClear.Add_Click{$txtContactNo.Clear()}
$btnClear.Add_Click{$txtAltContact.Clear()}
$btnClear.Add_Click{$txtDescription.Clear()}
$btnClear.Add_Click{$txtTMPSE.Clear()}
$btnClear.Add_Click{$txtReportedContact.Clear()}
$btnClear.Add_Click{$txtReportedBy.Clear()}
#Sets ComboBoxes to Please Select, Select and None on Main Page
$btnClear.Add_Click{$cboCustomer.SelectedIndex = 0}
$btnClear.Add_Click{$cboSpecialHandling.SelectedIndex = 0}
$btnClear.Add_Click{$cboPriority.SelectedIndex = 0}
$Rincewind.Controls.Add($btnClear)
The problem occurs with the { }
At home it works, Work nope. I cannot update Powershell on work computers.
Is there a better way to do this?