views:

48

answers:

2

I have a listview control, to this control I am adding rows which contain image data, filename, position (its taken at a point in a 4 dimensional matrix), time taken. To make things nice I want to add a 'delete' icon to my fourth column so the user can review the image and decide whether to keep it or not, how do I add an image/icon to that 4th cell in each row?

public void addItemToImageListview(string details, string timestamp)
{
        string reftype = (!exp_image_radiobtn.Checked) ? "Ref" : "Data";
        ListViewItem lvi = new ListViewItem();

        if (details.Contains("[ERROR]"))
        {
            reftype = "[ERROR]";
            details = details.Substring(0, details.IndexOf("[ERROR]"));
        }

        lvi.Text = details;
        lvi.SubItems.Add(reftype);
        lvi.SubItems.Add(timestamp);
        lvi.SubItems.Add(image icon?);

I have looked through Google but a lot of stuff is old...

As Aren asked, this is a winforms app, c#, 3.5.

+1  A: 

Unfortunately, in WinForms rendering a column as an image gets painful. You have to create an owner-drawn ListView and provide the logic for drawing that column.

Fortunately, there's the open source ObjectListView wrapper, which makes drawing images in ListView subitem columns trivial:

alt text

LBushkin
Thanks, i'm putting this down as answered though it wasn't really what I was looking for - this is a massive project. Thanks.
flavour404
Unfortunately, you don't really have many good options. Reworking a ListView to make it ownerdrawn is not much easier, and is definitely a way to introduce more problems (if you've never written a custom owner-draw control before).
LBushkin