Size szStandard = new Size();
public FrmMain()
{
InitializeComponent();
foreach (Control ctrl in this.Controls)
{
if (ctrl is PictureBox)
{
ctrl.MouseHover += new EventHandler(ctrl_MouseHover);
ctrl.MouseLeave += new EventHandler(ctrl_MouseLeave);
}
}
}
void ctrl_MouseLeave(object sender, EventArgs e)
{
PictureBox picbox = (PictureBox)sender;
picbox.Size = szStandard;
}
void ctrl_MouseHover(object sender, EventArgs e)
{
//每次放大图片原大小的20%
PictureBox picbox = (PictureBox)sender;
szStandard = picbox.Size;
picbox.Size = Size.Ceiling(new SizeF(picbox.Width * 1.2f, picbox.Height * 1.2f));
}
WinForm 鼠标经过图片 放大
最新推荐文章于 2024-11-08 11:49:53 发布