Reputation: 527
I have an ListView in which I load images but in case I don't find the image on disk I want to create one on the fly and add it to the list like in the pseudo code from the Else brach. Do you know how I would go about doing this?
If IO.File.Exists(fileName) Then
Dim myImage As System.Drawing.Image = Image.FromFile(fileName)
ImageList1.Images.Add(myImage)
Else
' Dim blackImage= create a black image
' ImageList1.Images.Add(blackImage)
End If
Upvotes: 0
Views: 85
Reputation: 60
Dim flag As New Bitmap(200, 100)
Dim flagGraphics As Graphics = Graphics.FromImage(flag)
Dim Black As Integer = 0
Dim BBuffer As Integer = 10
While BBuffer <= 100
flagGraphics.FillRectangle(Brushes.Black, 0, Black, 200, 10)
flagGraphics.FillRectangle(Brushes.Black, 0, BBuffer, 200, 10)
Black += 20
BBuffer += 20
End While
ImageList1.Images.Add(flag)
Upvotes: 1