Ich brauchte eine ImageList und alle Bilder waren in den Resources vorhanden. Demnach wäre es doch sinnvoll alle Images per Reflection der Resource zu entlocken und sie in die IamgeList einzufügen.
Private Function buildImageListFromResources() As ImageList
Dim liResourceImages As ImageList = New ImageList()
Dim dicEnumerator As IDictionaryEnumerator
Dim rReader As ResourceReader
With Assembly.GetExecutingAssembly
rReader = New ResourceReader(.GetManifestResourceStream(My.Resources.Resources.ResourceManager.BaseName & ".resources"))
End With
dicEnumerator = rReader.GetEnumerator
While dicEnumerator.MoveNext
If dicEnumerator.Value.GetType() = GetType(System.Drawing.Bitmap) Then
liResourceImages.Images.Add(dicEnumerator.Key, dicEnumerator.Value)
End If
End While
rReader.Close()
Return liResourceImages
End Function
Kommentare zum Snippet