Skip to content

Listview and image

yossi balan

Asked Mar 25, 2006, 12:59 AM EST1 answer
Share
LinkedInX
hi
i need to insert for each row in listview a diffrent image
how i can do it? when i try to do it i always see the sdame picture
thanks
have a nice day

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    Hi

    To set a different icon to each listviewitem ( forget WORD row )

    public void ImageGo( ListView MyView )

    {

    int MyNumber = 0;

    foreach ( ListViewItem AnItem in MyView.Items )

    {

    AnItem.ImageIndex = MyNumber;

    MyNumber++;

    }

    }

    well the idea is each ListViewItem has an IconIndex
    so if you have an ImageList that holds 4 Images then the first Icon has the Index = 0 then 1 and so on

    so you need to assign a different index to each listviewitem (row)
    this done by incrementing ++

    0