The enlargement of the picture we should make clear is: Picture in PictureBox, we enlarge actually on PictureBox itself.
The PictureBox needs to be set as follows:
1, Sizemode:zoom
Container control where PictureBox is located:
2, Autoscroll:true
To add a mouse wheel event:
this. PictureBox1. MouseWheel + = new mouseeventhandler (picturebox1_mousewheel);
Private BOOL Ismove=false;
Private Point Mousepos;
Private void Picturebox1_mousedown(ObjectSenderMouseEventArgsE
{
This.PictureBox1.Focus();
Ismove=true;
Mousepos=New Point(e.x, e.y);
}
Private void Picturebox1_mousewheel(Objectsender, System.Windows.Forms.MouseEventArgsE
{
if(E.delta >0) {
This.PictureBox1. Width = This.PictureBox1. Width *9/Ten;
This.PictureBox1. Height = This.PictureBox1. Height *9/Ten;
}Else{
This.PictureBox1. Width = This.PictureBox1. Width * One/Ten;
This.PictureBox1. Height = This.PictureBox1. Height * One/Ten;
}
}
void Picturebox1mouseup(ObjectSenderMouseEventArgsE
{
This.Ismove=false;
}
void Picturebox1mousemove(ObjectSenderMouseEventArgsE
{
if( This.Ismove) {
if((PictureBox1. Location.y
-Mousepos. Y + e.y) >0&& (PictureBox1. Location.x
-Mousepos. X + e.x) >0) {
PictureBox1. Location =New Point(PictureBox1. Location.x
-Mousepos. X + e.x,PictureBox1. Location.y
-Mousepos. Y + e.y);
}
}
}
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M02/7F/4D/wKioL1cZmBXjFbKcAAGs1_1yt98313.png "title=" 6hmh2u6y) 306kl56nypncuj.png "alt=" Wkiol1czmbxjfbkcaags1_1yt98313.png "/>
This article from the "Search in the Wind" blog, declined to reprint!
Drag the picture in the WinForm and adjust its zoom and abbreviation to prevent the picture out of range