I am trying to migrate from VB6 to VB.NET and I simply cannot get my head around the removal of the Key property in collections.
The latest headache this is causing me is a ListView, columns created at runtime which can potentially differ.To populate that ListView with data, I want to be able to say:
Me.ListView1.Items(1).SubItems("PhoneNumber").Text = "Example"
In VB6 it wasn't exactly obvious how to do this but you could use the expression:
Me.ListView1.ListItems(1).SubItems(Me.ListView1.ColumnHeaders("PhoneNumber").SubItemIndex).Text = "Example"
In VB.NET I see no way whatsoever to reference a ListView SubItem by anything other than a numeric index, and one which I have no control over at that. This same issue has caused me problems with TreeView Nodes, ImageList Images, Toolbar Buttons and several other controls which implement collections.
I know that technically I can use something called a HastTable to circumvent this inadequacy but I find HashTables more than a little inconvenient for my purposes. I am assuming that there must be people out there who used to write lines of code such as Me.ListView1.ListItems(1).SmallIcon = "OpenFolder" and have already had to change their way of thinking to accomodate the complete lack of text referencing for collections in VB.NET. What I really more than a way to work around this latest inconvenience is some guidence as to what I should be doing in order that I don't feel the need for the Key property, maybe in the form of a book recommendation, a URL about VB6 migration which addresses this issue or anything else which might leave me less puzzled.