Hi Peter,
Since there's a limitation of Panel's Height, I recommend you to load a
picture once a time, for example by clicking on a "Previous" button or a
"Next" button.
We could place all the pictures in a folder and make use of the
GetFileSystemInfos method of the DirectoryInfo class to get the
information
of all files in this folder, including the total count of these files and
each file's file name. Then we could navigate among all these files in our
program easily.
The following is a sample. It requires that you have set up a Windows
application and drag&drop a PictureBox, two Labels and two buttons onto
the
form.
using System.IO;
public class Form1 : System.Windows.Forms.Form
{
FileSystemInfo[] infos;
int position = -1;
private void Form1_Load(object sender, System.EventArgs e)
{
DirectoryInfo dir = new DirectoryInfo(@"C:\private\others\picures");
if (dir.Exists)
{
infos = dir.GetFileSystemInfos("*JPG");
this.label1.Text = infos.Length.ToString();
if (infos.Length > 0)
{
button2_Click(sender, e);
}
}
else
{
this.label1.Text = "0";
}
}
// click on button1 to navigate to the previous picture
private void button1_Click(object sender, System.EventArgs e)
{
if (position > 0)
{
position--;
this.pictureBox1.Image = Image.FromFile(infos[position].FullName);
}
this.label2.Text = (position + 1).ToString();
}
// click on button1 to navigate to the next picture
private void button2_Click(object sender, System.EventArgs e)
{
if (position < infos.Length - 1)
{
position++;
this.pictureBox1.Image = Image.FromFile(infos[position].FullName);
}
this.label2.Text = (position + 1).ToString();
}
Hope this helps.
If you don't think my workaround is suitable to your scenario, please feel
free to let me know.
Sincerely,
Linda Liu
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no
rights.