Hi Renz Pelias,
Here is a runnable example - please replace the picture path (D:\sample.jpg) to a valid path for your system:
using System;
using System.Drawing;
using System.Windows.Forms;
namespace AddPictureToListView
{
static class Program
{
[STAThread]
static void Main()
{
Form form = new Form();
PictureBox pb = new PictureBox { Dock = DockStyle.Top, Image = Bitmap.FromFile(@"D:\sample.jpg") };
ListView lv = new ListView { Dock = DockStyle.Fill };
lv.LargeImageList = new ImageList();
Button button = new Button { Text = "Add", Dock = DockStyle.Top};
button.Click += (object sender, EventArgs e) =>
{
string strKey = "Image" + lv.LargeImageList.Images.Count;
lv.LargeImageList.Images.Add(strKey, pb.Image);
ListViewItem item = new ListViewItem("Text representing image", strKey);
item.Tag = pb.Image;
lv.Items.Add(item);
};
form.Controls.Add(lv);
form.Controls.Add(button);
form.Controls.Add(pb);
Application.Run(form);
}
}
}
So the trick is to fill the image list(s) and wire up the listview items to it. I also added the original Image as Tag to the ListViewItem (maybe nice if you later want to do something with the original). There are two ways to wire the Images up, with keys - the approach I used in the example or just by index (more usefull for static Image list).
But I have to say that maybe a ListView is not ideal for your usecase. You can also use a Panel (Wrap,Panel) and just add PictureBoxes (or owner-draw it for better Performance) to it. (Don't forget to turn Scrolling on...)
If you have any further questions, feel free to ask - happy coding
Kind regards
Johannes