实现效果:
知识运用:
Panel控件的AutoScroll属性 //指定容器是否允许用户滚动到任何放置在其可见边界之外的控件
实现代码:
private void button1_Click(object sender, EventArgs e) { openFileDialog1.Filter = "*.jpg,*.jpeg,*.bmp,*.png,*.tif,*.wmf|*.jpg;*.jpeg;*.bmp;*.png;*.tif;*.wmf"; openFileDialog1.ShowDialog(); Image myImage = Image.FromFile(openFileDialog1.FileName); panel1.AutoScroll = true; pictureBox1.Image = myImage; pictureBox1.Width = myImage.Width; pictureBox1.Height = myImage.Height; }