Note: This is practice, details that follow are not confidential.
Hello all,
I have a drop down box containing 2 employees. I want to populate an hourly rate (£) text box which will be the result of which Employee is selected from the drop down. The hourly rate values are hard coded for now.
Below is the function I call for setting the Hourly Rate.
function SetHourlyRate { param( $WhichEmployee = $($EmployeeDropDownBox.SelectedItem) ) if ($WhichEmployee = "Mike Smith") { $HourlyRateTextBox.Text = "£11.60" } if ($WhichEmployee = "David Bloggs") { $HourlyRateTextBox.Text = "£12.20" } }
Below is the drop down box with selected value event:
$EmployeeList = @("Mike Smith", "David Bloggs") foreach ($Employee in $EmployeeList) { $EmployeeDropDownBox.Items.Add($Employee) } $EmployeeDropDownBox.add_SelectedValueChanged({ SetHourlyRate })
Selecting any employee sets the rate to £12.20, I am unable to display the £11.60 value. Is my $WhichEmployee variable not matching the if statements of “Mike Smith” or “David Bloggs”? I have tried using .selecteditem.ToString() also which did not work. The function seems to display whichever value is displayed last.
Thanks