June 2019 : This is still an issue an Microsoft clearly hasn't fixed it yet !
But thanks to David Amey we have a fix. You first need to create and add all your groups to the listview
Dim MyLvg As ListViewGroup = New ListViewGroup With {.Header = "MyGroup1", .Name = "MyGroup1"}
MyLsv.Groups.Add(MyLvg)
Only after that will you be able to add items.
I also figured out, at this stage it won't work if you declare a new ListViewItem from scratch and add it, but rather here you need to go through your existing ListView instance to create it. Then just link your Lvi to your Lsv and you're all set.
Dim MyLvi As ListViewItem = MyLsv.Items.Add("This is my new item")
MyLvi.Group = MyLvg
On a final note, let me add that I've tested 6 ways to link ListViewItems to ListViewGroups and all were working ok
MyLvi.Group = MyLvg
MyLvi.Group = MyLsv.Groups(0)
MyLvi.Group = MyLsv.Groups("MyGroup1")
MyLvg.Items.Add(MyLvi)
MyLsv.Groups(0).Items.Add(MyLvi)
MyLsv.Groups("MyGroup1").Items.Add(MyLvi)
This could seems logical, but we still don't get those bugs so I preferred to double check.
Using this way of creating and linking Groups and Items will definitely ensure you to avoid this "Bad Group Id" problem from LVHITTESTINFO