Populate checked listbox

Archived support forum for customers who once purchased a PrimalForms product license. This forum is locked.
This topic is 11 years and 11 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.
User avatar
DerekSchaulandMVP
Posts: 27
Last visit: Tue Dec 15, 2020 10:53 am

Populate checked listbox

Post by DerekSchaulandMVP »

I have a checked listbox being populated by the following code $grouplist = (get-adgroup -filter * | select-object Name) foreach($group in $grouplist){ $groups.items.add($group)} the box populates but returns @{Name=GroupName} for each line. All the contents are correct. How can I clean up the display to just show the group name?
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Populate checked listbox

Post by davidc »

Try this:$grouplist = (get-adgroup -filter * )foreach($group in $grouplist){ $groups.items.add($group.Name)} David
davidc2012-04-19 14:09:17
David
SAPIEN Technologies, Inc.
User avatar
DerekSchaulandMVP
Posts: 27
Last visit: Tue Dec 15, 2020 10:53 am

Populate checked listbox

Post by DerekSchaulandMVP »

That looks all kinds of better thanks
User avatar
DerekSchaulandMVP
Posts: 27
Last visit: Tue Dec 15, 2020 10:53 am

Populate checked listbox

Post by DerekSchaulandMVP »

Hmmm ok.. the plot thickens. Can I get more than one property to display in the list box? Name and GroupCategory?
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Populate checked listbox

Post by davidc »

You can always create a string that contains the information you want.For example: $groups.items.add("$($group.Name): $($group.GroupCategory)") The ListBox is very similar to the ComboBox. I recommend reading our Spotlight article on the ComboBox. David
davidc2012-04-19 15:45:02
David
SAPIEN Technologies, Inc.
User avatar
DerekSchaulandMVP
Posts: 27
Last visit: Tue Dec 15, 2020 10:53 am

Populate checked listbox

Post by DerekSchaulandMVP »

David - thanks again.. Powershell is one of those things that makes sense until you try it, looks like Im all set
This topic is 11 years and 11 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.