PowerShell and ListView

I was working on a PowerShell GUI tool with PowerShell Studio 2012 back in 2014.
Where the user can choose stuff with checkboxes.

First I used the checklistbox Control.
Works nice if you don’t want Groups, but I want that!

Group One
Checkbox One
Checkbox Two
Checkbox Three
Group Two
Checkbox Four
Checkbox Five
Checkbox Six
Group Three
Checkbox Seven

So I ended up using the ListView Control instead of the checklistbox Control.

But the way to a nice ListView with groups of checkboxes was not as easy that you can think.

A standard ListView with seven items looks like this:

Easiest way to add items is to go to Properties -> Items and click (Collection) …

And when adding checkboxes it will look like this:

Under properties you will find CheckBoxes. Default setting is False.
Change it to True.

I want my Checkboxes on the left side:

In properties change Alignment to Left:

But I want the checkbox on the left side of the text.
So I desided to change it from Large Icons to Small Icons and It will be nicer.

In properties change View to SmallIcon:

And now I start to fix the Groups.

Under Items we need to assign Groups to the Items.

And here is the result of this:

Not as nice as I hoped for.

I played around with this for a while and found out how to solv it.

The Details view is the right view with Groups and checkboxes, not the Small Icon view.
But as default it looks like this:

So I ended upp creating a default column.

And now the ListView is as I wanted it!
I did not find any posts on this strange behavor on the internet (back in 2014 when I first post this blog post
on PowerShellTaskForce.com).

But there are 3 nice blog posts on Sapiens blog about the ListView Control.

http://www.sapien.com/blog/2012/04/04/spotlight-on-the-listview-control-part-1/
http://www.sapien.com/blog/2012/04/05/spotlight-on-the-listview-control-part-2/
http://www.sapien.com/blog/2012/04/11/spotlight-on-the-listview-control-part-3/

 

 

 

 

 

 

 

 

You may also like...

8 Responses

  1. June 13, 2014

    New post: ‘PowerShell and ListView’ by @PowerShellTF at http://t.co/aUJ7PxJpEU

  2. June 16, 2014

    RT @vNiklas: PowerShell and ListView http://t.co/PSuzUiLeOK <- great post by @walle75 on @PowerShellTF blog

  3. June 16, 2014

    RT @vNiklas: PowerShell and ListView http://t.co/PSuzUiLeOK <- great post by @walle75 on @PowerShellTF blog

  4. June 16, 2014

    PowerShell and ListView http://t.co/WQ8pzL2E0l

  5. June 16, 2014

    PowerShell and ListView http://t.co/8br4lkUmcn por @walle75 en @PowerShellTF blog

  6. June 16, 2014

    RT @UCOMSSP: PowerShell and ListView http://t.co/8br4lkUmcn por @walle75 en @PowerShellTF blog

  7. June 19, 2014

    […] my last blog post I showed how to work with the ListView in PowerShell Studio to add Groups and […]

  8. June 23, 2014

    RT @vNiklas: PowerShell and ListView http://t.co/PSuzUiLeOK <- great post by @walle75 on @PowerShellTF blog

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.