Combobox example

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 8 years and 4 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
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Combobox example

Post by jvierra »

Dan - I think the question is how to use the combobox. The OP says he knows how to use Get-AdUser.
User avatar
localpct
Posts: 397
Last visit: Thu Oct 27, 2022 5:57 am

Re: Combobox example

Post by localpct »

I'm going to take a stab at answering what I think is my first PS question, so if I'm wrong, blame jvierra he taught me everything :)

So what you want to do is have a drop down that has info you've populated that I'm guessing you're using the Edit Items menu, When the technician hits a domain say D1 and presses the Go! Button, it gets a list of the users? will this work for you?

$button1_Click={
#TODO: Place custom script here
if ($combobox1.Text -eq "dc1")
{
$DisplayInfo.Text = Get-ADUser -Filter *

}

if ($combobox1.Text -eq "dc2")
{
$DisplayInfo.Text = Get-ADUser -Filter *

}
}

Is there a specific reason you want to use a button? If not, you can do this and get the same results

$combobox1_TextChanged={
#TODO: Place custom script here
if ($combobox1.Text -eq "dc1")
{
$DisplayInfo.Text = Get-ADUser -Filter *

}
}

FYI - $displayinfo.text is the name of my text box and I tried to wrap it using the code buttons but they're not working

Also, I'm with OP - the examples are designed for intermediate users and could provide real world examples such as this. Not, Red, Green, Blue or whatever colors they chose.
Attachments
10-29-2015 12-07-41 AM.png
10-29-2015 12-07-41 AM.png (8.35 KiB) Viewed 3472 times
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Combobox example

Post by jvierra »

Are you aware that your solutions will only ever display users from the current domain no matter which selection you choose?
User avatar
localpct
Posts: 397
Last visit: Thu Oct 27, 2022 5:57 am

Re: Combobox example

Post by localpct »

jvierra wrote:Are you aware that your solutions will only ever display users from the current domain no matter which selection you choose?
Nope but
1) I'm trying to give OP something to provide more feedback. This thread is 3 pages long without anything being added.
2) if I had a multi domain setup, I would have been able to test.
3) I blame you for my lack of knowledge ha ha ha.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Combobox example

Post by jvierra »

localpct wrote: Nope but
1) I'm trying to give OP something to provide more feedback. This thread is 3 pages long without anything being added.
2) if I had a multi domain setup, I would have been able to test.
3) I blame you for my lack of knowledge ha ha ha.
Then you did not follow the instructions to read the link I posted on page 1. Read the whole page of information and you both will have all of the answers and you will have discovered something very surprising. You might even call it a treat.
User avatar
localpct
Posts: 397
Last visit: Thu Oct 27, 2022 5:57 am

Re: Combobox example

Post by localpct »

We must come from different parts cause a treat to me is something that is handed without prying out info, I know exactly what you're doing but.... Regardless, I'm guessing it might be one of these two

($combobox1.SelectedItem.Equals = "dc1")

Or

($combobox1.SelectedIndex.Equals = "dc1")

Also, I'm not really sure if I need the .Equals =
I'm doing all of this off my phone.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Combobox example

Post by jvierra »

If you do not read the article you will never get it.
If has nothing to do with combo boxes.
User avatar
localpct
Posts: 397
Last visit: Thu Oct 27, 2022 5:57 am

Re: Combobox example

Post by localpct »

Read the article a few times last night and this morning and nothing is jumping out to me.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Combobox example

Post by jvierra »

localpct wrote:Read the article a few times last night and this morning and nothing is jumping out to me.
What article did you read? I hope it was this one: https://technet.microsoft.com/en-us/lib ... 2147217396
Remember I said it was not about a combobox.
User avatar
dan.potter
Posts: 709
Last visit: Wed Nov 14, 2018 11:39 am

Re: Combobox example

Post by dan.potter »

get-aduser... -server $combobox1.SelectedItem

might have to use text, I didn't try it.
This topic is 8 years and 4 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