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!
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
But there are 3 nice blog posts on Sapiens blog about the ListView Control.