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.
This topic is 5 years and 10 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
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: ListView subitems not showing in Tile view

Post by jvierra »

The following may give you some idea of how this works.
Attachments
Demo-ListViewTile.psf
(23.25 KiB) Downloaded 107 times
User avatar
MDinice
Posts: 20
Last visit: Sun Feb 19, 2023 4:27 pm

Re: ListView subitems not showing in Tile view

Post by MDinice »

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 1213 times
AddColHdr2.PNG
AddColHdr2.PNG (40.3 KiB) Viewed 1213 times
You are pretty much just adding bogus column headers for each line of text that you would like visible
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: ListView subitems not showing in Tile view

Post by jvierra »

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.
This topic is 5 years and 10 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