ImageList This component stores a list of images to be used by other controls or by the code. For example, one way to display an image on a ListView control is to create an ImageList component that will hold the images you want to use: First drag and drop the control to the Form, and then click the small arrow to its right: Then choose images you want your ImageList to hold: Finally set the control's SmallImageList property, selecting your ImageList from the list (ImageList1 in this case): add this code in the Browse button's click event: 1 For Each file As FileInfo In dir.GetFiles 2 ' set the image index according extension 3 Dim imageindex As Integer = 0 4 Select Case file.Extension 5 Case ".png", ".jpg", ".bmp", ".gif" 6 imageindex = 1 7 Case ".txt" 8 imageindex = 2 9 Case Else 10 ' an unknown format so we assign the document 11 imageindex = 0 12 End Select 13 14 Dim item As ListViewItem = imageindex) 15 item.SubItems.Add(file.LastWriteTime) 16 item.SubItems.Add(file.Extension) 17 item.SubItems.Add(String.Format("{0:n2} KB", Convert.ToDouble(file.Length / 1024))) 18 Next Voila!
ImageList This component stores a list of images to be used by other controls or by the code. For example, one way to display an image on a ListView control is to create an ImageList component that will hold the images you want to use: First drag and drop the control to the Form, and then click the small arrow to its right: Then choose images you want your ImageList to hold: Finally set the control's SmallImageList property, selecting your ImageList from the list (ImageList1 in this case): add this code in the Browse button's click event: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 For Each file As FileInfo In dir.GetFiles ' set the image index according extension Dim imageindex As Integer = 0 Select Case file.Extension Case ".png", ".jpg", ".bmp", ".gif" imageindex = 1 Case ".txt" imageindex = 2 Case Else ' an unknown format so we assign the document imageindex = 0 End Select Dim item As ListViewItem = imageindex) item.SubItems.Add(file.LastWriteTime) item.SubItems.Add(file.Extension) item.SubItems.Add(String.Format("{0:n2} KB", Convert.ToDouble(file.Length / 1024))) Next Voila!
ImageList.docx