I'm looking for a way to avoid using select case to access a specific list; I'll have about 90 lists on a module, and depending on a record selected on a listbox (manually populated with the name of most of the tables of my database, but not all of them) I need to read the items of the list. So I have something like this:
Public RelevantTables_Table001 As List(Of Table001) = New List(Of Table001)
Public RelevantTables_Table002 As List(Of Table002) = New List(Of Table002)
'...
Public RelevantTables_Table999 As List(Of Table999) = New List(Of Table999)
Class Table001
'code for populating RelevantTables_Table001
End Class
Class Table002
'code for populating RelevantTables_Table002
End Class
Class Table999
'code for populating RelevantTables_Table999
End Class
And now I need to read the relevant list, depending on an item picked on a listbox. For example if someone picks Table042 I need to read the items of the list RelevantTables_Table042.
I'm trying to use DirectCast for this, but I can't figure out how to do it.
Class:
Create new List:
Get the List object from the
SelectedItemproperty.To make a list of several objects(columns in a DGV) use a custom class:
Then your
Table.Collectionwould be aList(Of MyCustomClass)instead of a string, this will give you 3 items per collection items - which is a table. Does that fit your needs?