0

I hav two buttons & listview on the form,On First button click,i want to insert data & images into Lvw,On Second Button click,I want to just insert the data..Mine code also does that...
But just there is a little probs.On button1_Click, I assogn smallimagelist to imagelist name ,on Second button click,I assign to smallimagelist to nothing....Images are not inserted...on second button click,but still the images space(Left of lvw) are left, want to remove dat,How to do that..See pics atacched..TO understand it in better way..

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        ListView1.Columns.Clear()
        ListView1.Items.Clear()
        ImageList2.Images.Clear()

        ImageList2.Images.Add(ImageList1.Images.Item(0))
        ImageList2.Images.Add(ImageList1.Images.Item(1))
        ImageList2.Images.Add(ImageList1.Images.Item(2))
        ImageList2.Images.Add(ImageList1.Images.Item(3))
        ImageList2.Images.Add(ImageList1.Images.Item(4))


        ListView1.Columns.Add("aaa", 400, HorizontalAlignment.Center)
        ListView1.SmallImageList = ImageList2
        Dim lCount As Integer

        For lCount = 1 To 5
            ListView1.Items.Add(lCount.ToString, lCount - 1)
            Application.DoEvents()
        Next
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        ListView1.Columns.Clear()
        ListView1.Items.Clear()
        ImageList2.Images.Clear()

        ListView1.Columns.Add("First", 200, HorizontalAlignment.Center)
        ListView1.Columns.Add("Second", 200, HorizontalAlignment.Center)

        ListView1.SmallImageList = Nothing
        Dim lCount As Integer
        Dim lvitem As ListViewItem

        For lCount = 1 To 5
            lvitem = ListView1.Items.Add((lCount + 5).ToString)
            lvitem.SubItems.Add("Sonia" & lCount)
            Application.DoEvents()
        Next

    End Sub
2
Contributors
1
Reply
3
Views
7 Years
Discussion Span
Last Post by benlovedrum
0

Hello! (: Sonia thanks for the codes... I was wondering if I stored the picture is a certain folder and I want to access it and store it into the Listbox+Imagelist... How can it be done with your codes? (: Would mind giving me a sample program to review and understand? Hoping to hearing from you soon and God bless! (:

Benjamin
Email: benlovedrumming@hotmail.com

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.