CommonOpenFileDialog dialog = new CommonOpenFileDialog();
dialog.IsFolderPicker = true;
if (dialog.ShowDialog() == CommonFileDialogResult.Ok)
{
textBox1.Text = dialog.FileName;
}
string filePath = dialog.FileName;
this.listView1.OwnerDraw = true;
this.listView1.View = View.Tile;
DirectoryInfo di = new DirectoryInfo(filePath);
FileInfo[] afi = di.GetFiles("*.*");
string temp;
ListViewItem lvi;
for (int i = 0; i < afi.Length; i++)
{
if (Path.GetExtension(afi[i].ToString()) == ".jpg" || Path.GetExtension(afi[i].ToString()) == ".png" || Path.GetExtension(afi[i].ToString()) == ".gif" || Path.GetExtension(afi[i].ToString()) == ".bmp")
{
var img = Image.FromFile(filePath + @"\" + afi[0]);
int width = img.Width;
int height = img.Height;
this.listView1.TileSize = new Size(width, height);
temp = afi[i].Name.ToLower();
if (temp.EndsWith(".jpg"))
{
lvi = new ListViewItem();
lvi.Text = i.ToString();
lvi.Tag = afi[i].FullName;
this.listView1.Items.Add(lvi);
}
else if (temp.EndsWith(".png"))
{
lvi = new ListViewItem();
lvi.Text = i.ToString();
lvi.Tag = afi[i].FullName;
this.listView1.Items.Add(lvi);
}
else if (temp.EndsWith(".gif"))
{
lvi = new ListViewItem();
lvi.Text = i.ToString();
lvi.Tag = afi[i].FullName;
this.listView1.Items.Add(lvi);
}
else if (temp.EndsWith(".bmp"))
{
lvi = new ListViewItem();
lvi.Text = i.ToString();
lvi.Tag = afi[i].FullName;
this.listView1.Items.Add(lvi);
}
}
}
this.listView1.TileSize = new Size(width, height); sets a given size for all images in listview, how can i do this separately for each of them?