I followed the idea of KalaNag by putting my image box inside the panel and handling the event in the pciturebox folder, doing this
private void PictureBox_MouseEnter(object sender, EventArgs e) { PictureBox control = sender as PictureBox; (control.Parent as Panel).Width = 20; (control.Parent as Panel).Height = 20; (control.Parent as Panel).BorderStyle = BorderStyle.Fixed3D; } private void PictureBox_MouseLeave(object sender, EventArgs e) { PictureBox control = sender as PictureBox; (control.Parent as Panel).Width = 18; (control.Parent as Panel).Height = 18; (control.Parent as Panel).BorderStyle = BorderStyle.None; }
I changed the size of the control, because otherwise the picture continues to flicker when the mouse draws borders, when the cursor enters and leaves endlessly, since the borders change the size of the control.
It works like a charm!
source share