Page 1 of 1

ComboBox and ListBox trigger

Posted: Sun Feb 14, 2016 3:45 am
by saritM
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

Re: ComboBox and ListBox trigger

Posted: Sun Feb 14, 2016 5:05 am
by jvierra
Set the listbox contents in the ComboBox "SelectedIndexChanged" event which is the default event for the ComboBox.

Re: ComboBox and ListBox trigger

Posted: Mon Feb 15, 2016 12:36 am
by saritM
can you please show me an example?

Re: ComboBox and ListBox trigger

Posted: Mon Feb 15, 2016 4:20 am
by jvierra
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

Re: ComboBox and ListBox trigger

Posted: Mon Feb 15, 2016 4:53 am
by jvierra
The following is about the simplest example that I can come up with.

Re: ComboBox and ListBox trigger

Posted: Mon Feb 15, 2016 5:05 am
by saritM
$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

Re: ComboBox and ListBox trigger

Posted: Mon Feb 15, 2016 5:11 am
by jvierra
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