ListView subitems not showing in Tile view

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.
jvierra
Posts: 14000
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: ListView subitems not showing in Tile view

Post by jvierra » Tue Apr 17, 2018 8:55 pm

The following may give you some idea of how this works.
Attachments
Demo-ListViewTile.psf
(23.25 KiB) Downloaded 36 times

User avatar
MDinice
Posts: 20
Joined: Sat Apr 30, 2016 10:53 am

Re: ListView subitems not showing in Tile view

Post by MDinice » Wed May 02, 2018 7:56 pm

This does work. I did further research and found a Microsoft article
https://docs.microsoft.com/en-us/dotnet ... ew-control
The key is this line in the example:
// Add column headers so the subitems will appear.
myListView.Columns.AddRange(new ColumnHeader[]
{new ColumnHeader(), new ColumnHeader(), new ColumnHeader()});

I accomplished this in my code like this
# Add Columns so subitems are visible
$listview.Columns.Add("")
$listview.Columns.Add("")

and can be done in the designer like this
AddColHdr1.PNG
AddColHdr1.PNG (36.55 KiB) Viewed 550 times
AddColHdr2.PNG
AddColHdr2.PNG (40.3 KiB) Viewed 550 times
You are pretty much just adding bogus column headers for each line of text that you would like visible

jvierra
Posts: 14000
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: ListView subitems not showing in Tile view

Post by jvierra » Wed May 02, 2018 8:09 pm

Which is why I noted that in the beginning. Column headers are needed in the "Detail" view also.

If you look at my last example it displays the details but does not define columns. If you define the subitems in this way they will be set up correctly. If you want default images then you must define columns or individually code each subitem.

Locked