Change Combobox Item Text

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 6 years and 2 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
dank42
Posts: 61
Last visit: Tue Apr 26, 2022 7:49 am

Change Combobox Item Text

Post by dank42 »

Hi,

I am trying to make an item in my combobox change when it is selected for example:

The user selects "daniel.kitchen" from the combobox and it changes from "daniel.kitchen" to "1234"

What is the easiest way to do this?

Cheers
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Change Combobox Item Text

Post by jvierra »

You can't. Use a ListBox.
User avatar
dank42
Posts: 61
Last visit: Tue Apr 26, 2022 7:49 am

Re: Change Combobox Item Text

Post by dank42 »

Nice one, got it.
  1. $listbox1_SelectedIndexChanged={
  2.    
  3.     if ($listbox1.SelectedItem -eq "gardner.paterson")
  4.     {
  5.        
  6.         $combobox_staff_manager.Text = "10010"
  7.        
  8.     }
  9.  
  10. }
Thanks
This topic is 6 years and 2 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked