Author Posts

March 21, 2017 at 10:59 am

I am rather new to Powershell coding and trying to cut down on some code.

I have multiple ComboBoxes that have the same selection.

How can I use the same lists for different Comboboxes but using minimum code?

i.e. I have 10 Comboboxes that have the lists of Please Select, Yes, No.
How can I get them to use the same line of code instead of individual code?

#Adding Combobox Items to Toner Colour
    "Select","Yes","No" | ForEach-Object {$WPFcboPRToner.AddChild($_)}
    $WPFcboPRToner.SelectedIndex = 0

So in the code I want other comboboxes to use this without duplicating code.

Thanks All.

Chris

March 21, 2017 at 12:53 pm

Add the line(s) of code to a variable and use the variable.