如何解决具有下推效果的按钮的代码? VB.net
如何让按钮具有下推效果?我不是在谈论 FlatStyle popup
。它必须“向下”,可以这么说,在第二次点击它时,它会在鼠标点击结束时“向上”。
这是我迄今为止尝试过的代码。你有更好的想法吗?
Dim RememberXpos As Integer = Button1.Location.X
Dim RememberYpos As Integer = Button1.Location.Y
Dim ButtonXEnd As Integer = Button1.Location.X + Button1.Size.Width
Dim ButtonYEnd As Integer = Button1.Location.Y + Button1.Size.Height
Dim oldSize As Size = Button1.Size
' shrink
Button1.Size = New Size(CInt(Button1.Size.Width * 0.9),CInt(Button1.Size.Height * 0.9))
' center the button
Dim ButtonXEndeDiffHalf As Integer = CInt(Math.Round((ButtonXEnd - (Button1.Location.X + Button1.Size.Width)) / 2.0,0))
Dim ButtonYEndeDiffHalf As Integer = CInt(Math.Round((ButtonYEnd - (Button1.Location.Y + Button1.Size.Height)) / 2.0,0))
Button1.Location = New Point(Button1.Location.X + ButtonXEndeDiffHalf,Button1.Location.Y + ButtonYEndeDiffHalf)
Button1.Update()
System.Threading.Thread.Sleep(150)
' re-enlarge
Button1.Size = oldSize
Button1.Location = New Point(RememberXpos,RememberYpos)
解决方法
改用复选框并将外观设置为按钮。
CheckBox1.Appearance = Appearance.Button
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。