private void button2_Click(object sender, EventArgs e)
{
openFileDialog1.Filter = "*jpg|*JPG|*GIF|*.BMP";
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
string fullpath = openFileDialog1.FileName;
//图片异步加载完成后的处理事件
pictureBox1.LoadCompleted += new AsyncCompletedEventHandler(pictureBox1_LoadCompleted);
//图片加载时,显示等待光标
pictureBox1.UseWaitCursor = true;
//采用异步加载方式
pictureBox1.WaitOnLoad = false;
Bitmap bm = new Bitmap(fullpath);
Point pt = new Point(bm.Size );
if (pt.X > pictureBox1.Size.Width || pt.Y > pictureBox1.Size.Height)
{
pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
}
else
{
pictureBox1.SizeMode = PictureBoxSizeMode.CenterImage;
}
//开始异步加载,图片的地址,请自行更换
//pictureBox1.LoadAsync("http://www.);
pictureBox1.LoadAsync(fullpath );
}
}
void pictureBox1_LoadCompleted(object sender, AsyncCompletedEventArgs e)
{
//图片加载完成后,将光标恢复
pictureBox1.UseWaitCursor = false;
}
呵呵 这个准行