Support Forums

ComboBox and ListBox trigger

Ask your Windows PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.
User avatar
saritM
Posts: 3
Joined: Sun Feb 14, 2016 4:43 am

ComboBox and ListBox trigger

Postby saritM » Sun Feb 14, 2016 4:45 am

Hello,

I have windows form with combobox and listbox.
I want that once item selected in the combobox, the items in the listbox will change accordingly
tried million of options but nothing is working.
can someone please help?

thanks,
Sarit
User avatar
jvierra
Posts: 9736
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: ComboBox and ListBox trigger

Postby jvierra » Sun Feb 14, 2016 6:05 am

Set the listbox contents in the ComboBox "SelectedIndexChanged" event which is the default event for the ComboBox.
User avatar
saritM
Posts: 3
Joined: Sun Feb 14, 2016 4:43 am

Re: ComboBox and ListBox trigger

Postby saritM » Mon Feb 15, 2016 1:36 am

can you please show me an example?
User avatar
jvierra
Posts: 9736
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: ComboBox and ListBox trigger

Postby jvierra » Mon Feb 15, 2016 5:20 am

Just load your listbox in the event.

I have no idea what you are trying to accomplish as you question is very vague:

Here are many examples of how to use a combobox. Perhaps I twill help. https://www.google.com/?gws_rd=ssl#neww ... n+combobox
User avatar
jvierra
Posts: 9736
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: ComboBox and ListBox trigger

Postby jvierra » Mon Feb 15, 2016 5:53 am

The following is about the simplest example that I can come up with.
Attachments
Demo-SimpleComboRelation.psf
(21 KiB) Downloaded 95 times
User avatar
saritM
Posts: 3
Joined: Sun Feb 14, 2016 4:43 am

Re: ComboBox and ListBox trigger

Postby saritM » Mon Feb 15, 2016 6:05 am

$combobox2_SelectedIndexChanged={
#TODO: Place custom script here
param (
[string]$DisplayMember_CB_LDST = ["LDST-TGB-BES01", "LDST-TGB-BES02"],
[string]$DisplayMember_CB_MAST = ["MAST-TGA-BES01", "MAST-TGA-BES02"]
)

if ($combobox1.SelectedIndex -eq "Staging")
{
if ($combobox2.SelectedIndex -eq "UK")
{
Load-ListBox -ListBox $listBox1 -Items $DisplayMember_CB_LDST
}
else
{
if ($combobox1.Items -eq "Staging")
{
if ($combobox2.Items -eq "Latam")
{
$checkedlistbox1.SelectedIndex = $DisplayMember_CB_MAST
}

}
}
}
}

this is my code.. im a beginner in PS so I guess im missing something
User avatar
jvierra
Posts: 9736
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: ComboBox and ListBox trigger

Postby jvierra » Mon Feb 15, 2016 6:11 am

Sorry but your code does not make any sense to me. I recommend leaningPowerSHell before attempting to use forms. YOu APara statement is syntactically impossible and is throwing errors. Look up the help on each of these items and read the details.

I am sorry but a forum is not the right place to teach PowerShell. Search for books and sites teaching PowerSHell.

Here is one place to start: https://mva.microsoft.com/en-us/trainin ... 2304984382

Return to “Windows PowerShell”

Who is online

Users browsing this forum: No registered users and 4 guests