ListView and Icons

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Simon Morris

    #1

    ListView and Icons

    How do you add I icon to a ListView at run time, the icon is in a ImageList
    (ImageIndex = 0)? I am using the follow code to add item.



    Dim item4 As New ListViewItem("L oad Island Data", 1)

    item4.SubItems. Add(Format(Micr osoft.VisualBas ic.Timer - sngStartTime, "0.0"
    & " sec"))

    item4.SubItems. Add("All map data loaded in to memory")

    TaslList.Items. AddRange(New ListViewItem() {item4})



  • Ed Kaim [MSFT]

    #2
    Re: ListView and Icons

    I often cheat and do something like:

    Me.ListView1.Sm allImageList.Im ages.Add(MyNewI temIcon)

    Me.ListView1.It ems.Add(MyItemT ext,
    Me.ListView1.Sm allImageList.Im ages.Count - 1)



    First it adds the image I want to use to the ListView's small image list.
    Then it adds a new item and points the image to the last image in the small
    image list, which is the one I just added. I don't recommed this if you're
    going to be adding a lot of images because it will end up eating a lot of
    memory. It should be fine if you're just doing a runtime population of the
    control and won't be adding more afterwards.

    "Simon Morris" <nzavalanche@ho tmail.com> wrote in message
    news:utniPIvqDH A.2688@TK2MSFTN GP09.phx.gbl...[color=blue]
    > How do you add I icon to a ListView at run time, the icon is in a[/color]
    ImageList[color=blue]
    > (ImageIndex = 0)? I am using the follow code to add item.
    >
    >
    >
    > Dim item4 As New ListViewItem("L oad Island Data", 1)
    >
    > item4.SubItems. Add(Format(Micr osoft.VisualBas ic.Timer - sngStartTime,[/color]
    "0.0"[color=blue]
    > & " sec"))
    >
    > item4.SubItems. Add("All map data loaded in to memory")
    >
    > TaslList.Items. AddRange(New ListViewItem() {item4})
    >
    >
    >[/color]


    Comment

    Working...