I want to zoom-in or zoom-out a image on picturebox using mouse wheels in c#.How Can i do?
Sivodaya Tech
This topic helps to zoom in and out picture in picturebox
add below code inside the picturebox mouse wheel event
if (e.Delta != 0) {
if (e.Delta <= 0) {
//set minimum size to zoom
if (PictureBox1.Width < 50)
return;
} else {
//set maximum size to zoom
if (PictureBox1.Width > 500)
return;
}
PictureBox1.Width += Convert.ToInt32(PictureBox1.Width * e.Delta / 1000);
PictureBox1.Height += Convert.ToInt32(PictureBox1.Height * e.Delta / 1000);
}
Use the MouseWheel event : http://msdn.microsoft.com/fr-fr/library/system.windows.forms.control.mousewheel%28v=vs.80%29
来源:https://stackoverflow.com/questions/11734934/how-to-zoom-in-and-zoom-out-a-image-in-picturebox-using-mouse-wheels-in-c