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
User avatar
ianstraw
Posts: 29
Last visit: Wed Oct 28, 2015 8:22 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
Last visit: Thu Oct 22, 2015 1:10 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
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: Combobox example

Post by davidc »

[POST MOVED BY MODERATOR]
David
SAPIEN Technologies, Inc.
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 »

You post is too vague. Can you provide a clear example of what you are trying to do?
User avatar
ianstraw
Posts: 29
Last visit: Wed Oct 28, 2015 8:22 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: 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 »

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
Last visit: Wed Oct 28, 2015 8:22 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: 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 »

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
Last visit: Wed Oct 28, 2015 8:22 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: 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 »

You want $combobox1.SelectedItem in your button event or use $combobox1.Text.
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