image list, listview,picturebox
Posted
by
user548694
on Stack Overflow
See other posts from Stack Overflow
or by user548694
Published on 2010-12-28T19:50:50Z
Indexed on
2010/12/28
19:54 UTC
Read the original article
Hit count: 158
c#
I wanted to show my pics in picturebox. but also wanted to show a preview of pics. When user select a pic, it is shown in picbox but i have problem in resoulution.
Here is my code private void openToolStripMenuItem_Click(object sender, EventArgs e) {
ofd = new OpenFileDialog();
ofd.Title = "Open an Image File";
ofd.FileName = "";
ofd.Filter = "Image Files(*.jpg; *.jpeg; *.gif; *.bmp)|*.jpg; *.jpeg; *.gif; *.bmp";
if (ofd.ShowDialog() == DialogResult.OK)
{
DirectoryInfo dir = new DirectoryInfo(@"c:\pic");
foreach (FileInfo file in dir.GetFiles())
{
this.imageList1.Images.Add(Image.FromFile(file.FullName));
}
this.listView1.View = View.LargeIcon;
this.imageList1.ImageSize = new Size(40, 40);
this.listView1.LargeImageList = this.imageList1;
for (int j=0; j < this.imageList1.Images.Count; j++) {
ListViewItem item = new ListViewItem();
item.ImageIndex = j;
listView1.Items.Add(item);
ListViewItem item2 = new ListViewItem();
item2.SubItems.Add(j.ToString());
}
private void listView1_SelectedIndexChanged(object sender, EventArgs e) {
int i = this.listView1.FocusedItem.Index;
this.PicBox1.Image = this.imageList1.Images[i];
}
On click i see only image of resolution of (40,40) becuse i have set it this.imageList1.ImageSize = new Size(40, 40); and not orignal size. How can I have it. 2- I want to write also image names and index(image no) under each images. Its it possible. reagrsd,
© Stack Overflow or respective owner