去 msdn 查ScrollBar , 里面有解决问题的例子

解决方案 »

  1.   

    把PictureBox 放到一个 Panel里面, 设置PictureBox的父控件为那个Panel,然后Panel的AutoScroll属性为true
      

  2.   

    我的ScrollBar是放在了里面好使,仅供参考:
    private void pictureBox2_DoubleClick(object sender, System.EventArgs e)
    {
    if(openFileDialog1.ShowDialog() != DialogResult.Cancel)
    {
    pictureBox2.Image = Image.FromFile(openFileDialog1.FileName);
    this.DisplayScrollBars();
    this.SetScrollBarValues();
    } } public void DisplayScrollBars()
    {
    if (pictureBox2.Width > pictureBox2.Image.Width - this.vScrollBar1.Width)
    {
    hScrollBar2.Visible = false;
    }
    else
    {
    //在picturebox控件中添加一个水平滚动条
    pictureBox2.Controls.Add (hScrollBar2); 
    hScrollBar2.Left =0;
    hScrollBar2.Width =pictureBox2.Width ;
    hScrollBar2.Dock =System.Windows .Forms .DockStyle .Bottom ;
    hScrollBar2.Visible = true;
    }
    if (pictureBox2.Height > pictureBox2.Image.Height - this.hScrollBar2.Height)
    {
    vScrollBar2.Visible = false;
    }
    else
    {
    //在picturebox控件中添加一个垂直滚动条
    pictureBox2.Controls.Add (vScrollBar2); 
    vScrollBar2.Top =0;
    vScrollBar2.Height  =pictureBox2.Height  ;
    vScrollBar2.Dock =System.Windows .Forms .DockStyle.Right;
    vScrollBar2.Visible = true;
    }
    }

    public void SetScrollBarValues() 
    {
    this.vScrollBar2.Minimum = 0;
    this.hScrollBar2.Minimum = 0;
    if( (this.pictureBox2.Image.Size.Width - pictureBox2.ClientSize.Width) > 0)
    {
    this.hScrollBar2.Maximum = this.pictureBox2.Image.Size.Width - pictureBox2.ClientSize.Width;
    }
    if(this.vScrollBar2.Visible)
    {
    this.hScrollBar2.Maximum += this.vScrollBar2.Width;
    }
    this.hScrollBar2.LargeChange = this.hScrollBar2.Maximum / 10;
    this.hScrollBar2.SmallChange = this.hScrollBar2.Maximum / 20;
    this.hScrollBar2.Maximum += this.hScrollBar2.LargeChange;  
    if( (this.pictureBox2.Image.Size.Height - pictureBox2.ClientSize.Height) > 0)
    {
    this.vScrollBar2.Maximum = this.pictureBox2.Image.Size.Height - pictureBox2.ClientSize.Height;
    }
    if(this.hScrollBar2.Visible)
    {
    this.vScrollBar2.Maximum += this.hScrollBar2.Height;
    }
    this.vScrollBar2.LargeChange = this.vScrollBar2.Maximum / 10;
    this.vScrollBar2.SmallChange = this.vScrollBar2.Maximum / 20;
    this.vScrollBar2.Maximum += this.vScrollBar2.LargeChange;
    } private void HandleScroll(Object sender, ScrollEventArgs se)
    {
    Graphics g = pictureBox2.CreateGraphics();
    g.DrawImage(pictureBox2.Image, 
    new Rectangle(0, 0, pictureBox2.Right - vScrollBar2.Width,pictureBox2.Bottom - hScrollBar2.Height), 
    new Rectangle(hScrollBar2.Value, vScrollBar2.Value,pictureBox2.Right - vScrollBar2.Width,pictureBox2.Bottom - hScrollBar2.Height), 
    GraphicsUnit.Pixel);
    pictureBox2.Update();
    }