How to use Mouse_Wheel to zoom in & out pictureBox ...
i use this code :
namespace Test_Code_Csharp
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
pictureBox1.MouseWheel += new MouseEventHandler(pictureBox1_MouseWheel);
}
void pictureBox1_MouseWheel(object sender, MouseEventArgs e)
{
pictureBox1.Height += e.Delta / 60;
pictureBox1.Width += e.Delta / 60;
pictureBox1.Top -= e.Delta / 120;
pictureBox1.Left -= e.Delta / 120;
}
But no happen ! no error ! and no ...
Loading

VulpesPosted Sep 3, 2014, 9:18 AM
When I tried it myself, I added the MouseEnter event through the Properties Box at design time.
When I subsequently posted it, I added the event dynamically instead as that's what you'd done for the MouseWheel event. Unfortunately, I forgot that MouseEnter is an EventHandler rather than a MouseEventHandler delegate.
If you change:
ghasem dehPosted Sep 3, 2014, 9:04 AM
VulpesPosted Sep 3, 2014, 7:33 AM
What error are you getting?
ghasem dehPosted Sep 3, 2014, 3:29 AM
use this But : error in MouseEnter Method ...
and when use just pictureBox1.Focus ...
not happen !
VulpesPosted Sep 2, 2014, 1:32 PM
The problem with pictureboxes is that they don't normally receive focus even when they're clicked so the trick is to force focus onto them when (say) the mouse moves over them. The MouseWheel event will then fire.
You also need to set the picturebox's SizeMode property to zoom when its size changes.
Try this: