1
我試圖用海報和DVD收藏的標題填充列表視圖(瓷磚),但只有標題變得易於使用。listview瓷磚沒有顯示圖像(.NET2.0,VB,winforms)
這是我的代碼:?
Private Sub fillListView(ByVal listView As System.Windows.Forms.ListView, ByVal col As Collection)
listView.Items.Clear()
myImageList = New ImageList()
For Each item As bsDVD In col
Try
myImageList.Images.Add(Image.FromFile(Application.StartupPath & item.PosterURL))
Catch ex As Exception
MessageBox.Show(ex.message)
End Try
Next
myImageList.ImageSize = New Size(32, 32)
listView.LargeImageList = myImageList
For Each item As bsDVD In col
listView.Items.Add(item.Titel)
Next
End Sub
嘗試了很多不能讓它的工作:(我都做一個愚蠢的錯誤還是希望有人能幫助我
TY提前
TY都幫了我......
解決方案代碼:
Private Sub fillListView(ByVal listView As System.Windows.Forms.ListView, ByVal col As Collection)
listView.Items.Clear()
myImageList = New ImageList()
myImageList.ImageSize = New Size(70, 100)
myImageList.ColorDepth = ColorDepth.Depth24Bit
For Each item As bsDVD In col
Try
myImageList.Images.Add(Image.FromFile(Application.StartupPath & item.PosterURL))
Catch ex As Exception
MessageBox.Show("Kan afbeelding niet inladen!")
End Try
Next
listView.LargeImageList = myImageList
Dim mItem As bsDVD
For i As Integer = 1 To col.Count
mItem = CType(col.Item(i), bsDVD)
listView.Items.Add(mItem.Titel)
listView.Items(i - 1).ImageIndex = (i - 1)
Next
End Sub