1. private void AddImageToThumbnail(string[] images)
    {
    int top = 0;
    int ht = 150;
    int counter = 0;

    PictureBox[] pictures = new PictureBox[images.Length];

    if (images.Length > 0)
    {
    //The panel pnlThumbnail will hold thumbnail pictures.
    pnlThumbnail.AutoScroll = true;

    foreach (string image in images)
    {
    try
    {
    pictures[counter] = new PictureBox();
    pictures[counter].Parent = pnlThumbnail;
    pictures[counter].Top = top;
    pictures[counter].Height = ht;
    pictures[counter].Width = pnlThumbnail.Width - 10;
    pictures[counter].Image = new Bitmap(image);
    pictures[counter].BorderStyle = BorderStyle.FixedSingle;
    top += pictures[counter].Size.Height + 5;

    pictures[counter].SizeMode = PictureBoxSizeMode.StretchImage;
    pictures[counter].Show();

    //If user clicks on a picture then this event gets triggered, it can be used to display the current image.
    pictures[counter].Click += new EventHandler(fImage_Click);
    pictures[counter].ImageLocation = image;

    counter++;
    textThumbnailCount.Text = counter.ToString();
    }
    catch
    {
    //Error handler
    }
    }

    //Show the first image in the thumbnail
    //fImage_Click(pictures[0], null);
    }
    }


    Calling function:
    string[] images = Directory.GetFiles(@"C:\Temp\Images\", "*.tif");
    AddImageToThumbnail(images);
    0

    Add a comment

Blog Archive
Topics
Topics
Loading
Dynamic Views theme. Powered by Blogger. Report Abuse.