关于鼠标划过控件放大的问题

sardineany sardineany 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
我现在要实现的功能是鼠标划过一个butto 这个Button放大,然后离开的时候,这个button又恢复原貌。
我的实现代码是:
 private void timer1_Tick(object sender, EventArgs e)
{
if (simpleButton1.Height < 50 )
{
simpleButton1.Height += 3;

}
if (simpleButton1.Width < 100)
{
simpleButton1.Width += 6;
simpleButton1.Size = "1,1";
}

}


private void simpleButton1_MouseEnter(object sender, EventArgs e)
{
timer1.Enabled = true;
timer2.Enabled = false;
}

private void timer2_Tick(object sender, EventArgs e)
{
if ( simpleButton1.Width > 46)
{
simpleButton1.Width -= 6;
}
if (simpleButton1.Height > 23)
{
simpleButton1.Height -= 3;
}
}

private void simpleButton1_MouseLeave(object sender, EventArgs e)
{
timer1.Enabled = false;
timer2.Enabled = true;
}


这样有一个问题就是,他的改变是将左上角的一点固定然后进行放大和缩小,看着很僵硬,我想知道,可不可以让这个button从他的中心开始放大和缩小。。本人是新手,希望各位高手不吝赐教。。小弟这里谢过了
...全文
评论 11
收藏 已收藏
分享
返回顶部
sardineany
C# 111,129 成员 642,539 内容