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.
User avatar
ianstraw
Posts: 29
Joined: Thu Apr 23, 2015 3:16 am

Combobox example

Post by ianstraw »

Hi, can anyone start me off or provide an example of a combox box that does the following. I have tried the spotlights but i am still struggling.

Basically have a combo box listing domain so for example d1, d2, d3
which ever domain is selected you hit a button and it does something such as get-aduser *

Thanks

User avatar
SAPIEN Support Forums
Posts: 945
Joined: Wed Dec 03, 2014 2:26 pm

Combobox example

Post by SAPIEN Support Forums »

This is an automated post. A real person will respond soon.

Thank you for posting, ianstraw.

Did you remember to include the following?
  • 1. Product, version and build (e.g. Product: PowerShell Studio 2014, Version & Build: 4.1.71. Version and build information can be found in the product's About box accessed by clicking the blue icon with the 'i' in the upper right hand corner of the ribbon.)
    2. Specify if you are running a 32 or 64 bit version
    3. Specify your operating system and if it is 32 or 64 bit.
    4. Attach a screenshot if your issue can be seen on the screen
    5. Attach a zip file if you have multiple files (crash reports, log entries, etc.) related to your issue.
If not, please take a moment to edit your original post or reply to this one.

*** Make sure you do not post any licensing information ***

User avatar
davidc
Posts: 5913
Joined: Thu Aug 18, 2011 4:56 am

Re: Combobox example

Post by davidc »

[POST MOVED BY MODERATOR]
David
SAPIEN Technologies, Inc.

jvierra
Posts: 14614
Joined: Tue May 22, 2007 9:57 am
Answers: 2
Has voted: 1 time
Been upvoted: 3 times
Contact:

Re: Combobox example

Post by jvierra »

You post is too vague. Can you provide a clear example of what you are trying to do?

User avatar
ianstraw
Posts: 29
Joined: Thu Apr 23, 2015 3:16 am

Re: Combobox example

Post by ianstraw »

I want a combo box that lists several domains. once the required domain is selected a button is pressed that then runs some code on that domain that was selected.

jvierra
Posts: 14614
Joined: Tue May 22, 2007 9:57 am
Answers: 2
Has voted: 1 time
Been upvoted: 3 times
Contact:

Re: Combobox example

Post by jvierra »

What is it that you cannot figure out? Have you tried to build a form? What part don't you understand?

Try this: https://www.sapien.com/blog/?s=combobox

User avatar
ianstraw
Posts: 29
Joined: Thu Apr 23, 2015 3:16 am

Re: Combobox example

Post by ianstraw »

I have created the form and the combo box. I have populated the combox box with the domains. What i cant figure out is how to take the domain selected in the box and run the code on that domain. If you have 3 domains dc1,dc2,dc3 where in the code is this stored? how do you take that value and run it with some other code.

jvierra
Posts: 14614
Joined: Tue May 22, 2007 9:57 am
Answers: 2
Has voted: 1 time
Been upvoted: 3 times
Contact:

Re: Combobox example

Post by jvierra »

Where is what stored? The combobox has the strings you have placed in it.

The current value of the combobox is in the "Text" property.

Did you read the blog article. It explains how to use the combobox.

User avatar
ianstraw
Posts: 29
Joined: Thu Apr 23, 2015 3:16 am

Re: Combobox example

Post by ianstraw »

Yes ive read every blog re this hence the reason im asking for help.
To reiterate...

The combox box has a selection of domains which are the "strings"
When a user selects one of these domains from the drop down box and clicks a GO button it performs an action such as get-aduser *

I need to understand how the code works. So it the user selects domain 1 from the combo box and does that then feed into the action of get-aduser *

Thanks

jvierra
Posts: 14614
Joined: Tue May 22, 2007 9:57 am
Answers: 2
Has voted: 1 time
Been upvoted: 3 times
Contact:

Re: Combobox example

Post by jvierra »

You want $combobox1.SelectedItem in your button event or use $combobox1.Text.

Locked