111,120
社区成员
发帖
与我相关
我的任务
分享
this.MouseWheel += new System.Windows.Forms.MouseEventHandler(this.panel1_MouseWheel);
private void panel1_MouseWheel(object sender, System.Windows.Forms.MouseEventArgs e)
{
MessageBox.Show("滚动事件已被捕捉");
System.Drawing.Size t = pictureBox1.Size;
t.Width += e.Delta;
t.Height += e.Delta;
pictureBox1.Width = t.Width;
pictureBox1.Height = t.Height;
}
private void panel1_Scroll(object sender, ScrollEventArgs e)
{
int n =(int)Math.Truncate(Convert.ToDouble(e.NewValue / 400));//picturebox大小为800*400
if (n >= 1)
{
picBox1.Location = new Point(0, (n - 1) * 400);
picBox2.Location = new Point(0, n * 400);
picBox3.Location = new Point(0, (n + 1) * 400);
//dt是从数据库中读取的待显示图片的路径
picBox1.ImageLocation = dt.Rows[n - 1]["FilePath"].ToString();
picBox2.ImageLocation = dt.Rows[n]["FilePath"].ToString();
picBox3.ImageLocation = dt.Rows[n + 1]["FilePath"].ToString();
}
}