Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Using ImageList with Listview Question

Using ImageList with Listview Question

Scheduled Pinned Locked Moved Visual Basic
questionxml
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    japel
    wrote on last edited by
    #1

    I have a app with a listview on a form set to detailsview. This works great but now I would like to add small image icons. In the listview controle is a "smallimagelist" property that is set to none and I can not change that...? Below is the code I use to populate the listview on load.... How can I modify my code to allow small icon view mode? Public Sub ReloadListviewFromXML() Dim AddressBook As String = (Path.Combine(Application.StartupPath, "AddressBook.xml")) Dim ds As New DataSet Try ds.ReadXml(AddressBook) Dim dt As DataTable = ds.Tables("People") Dim i As Integer Dim j As Integer Me.listviewObjects.Items.Clear() For i = 0 To dt.Rows.Count - 1 Dim dr As DataRow = dt.Rows(i) With Me.listviewObjects .Items.Add(dr(0)) For j = 1 To dt.Columns.Count - 1 .Items(i).SubItems.Add(dr(j)) Next End With Next Catch ex As System.Exception End Try listviewObjects.GridLines = True listviewObjects.FullRowSelect = True listviewObjects.MultiSelect = True End Sub Thanks...

    When people make you see red, be thankful your not colour blind.

    N 1 Reply Last reply
    0
    • J japel

      I have a app with a listview on a form set to detailsview. This works great but now I would like to add small image icons. In the listview controle is a "smallimagelist" property that is set to none and I can not change that...? Below is the code I use to populate the listview on load.... How can I modify my code to allow small icon view mode? Public Sub ReloadListviewFromXML() Dim AddressBook As String = (Path.Combine(Application.StartupPath, "AddressBook.xml")) Dim ds As New DataSet Try ds.ReadXml(AddressBook) Dim dt As DataTable = ds.Tables("People") Dim i As Integer Dim j As Integer Me.listviewObjects.Items.Clear() For i = 0 To dt.Rows.Count - 1 Dim dr As DataRow = dt.Rows(i) With Me.listviewObjects .Items.Add(dr(0)) For j = 1 To dt.Columns.Count - 1 .Items(i).SubItems.Add(dr(j)) Next End With Next Catch ex As System.Exception End Try listviewObjects.GridLines = True listviewObjects.FullRowSelect = True listviewObjects.MultiSelect = True End Sub Thanks...

      When people make you see red, be thankful your not colour blind.

      N Offline
      N Offline
      Nico van der Plas
      wrote on last edited by
      #2

      Hi Japel, You don't need to modify your code. Just add an imagelist from the toolbox to your form and add some images to it. Click on your listview and set the property 'SmallImageList' to the imagelist you've just added. However, if you want to use different images for different items in your listview, I suggest that you modify your code so that it uses ListviewItems. Regards, Nico

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups