The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

DD in AK (1) [Avatar] Offline
#1
I'm trying to use Group By to populate a TreeView. The following nested query works fine, however, I'm not able to get similar results using the VB version of Listing422.

Dim Listing421 = From publisher In SampleData.Publishers
Select New With {.Publishers = publisher.Name,
.Books = (From book In SampleData.Books
Where book.Publisher.Name = publisher.Name)}

Dim CurrentNode As TreeNode
For Each item In Listing421
CurrentNode = TreeView1.Nodes.Add(item.Publishers)
For Each subitem In item.Books
CurrentNode.Nodes.Add(subitem.Title)
Next
Next

Dim Listing422 = From book In SampleData.Books
Group book By publisher = book.Publisher
Into publisherBooks = Group
Select New With {.Publisher = publisher.Name, .Books = publisherBooks}

'TreeView code ...