简体   繁体   English

VB.Net-工具栏按钮鼠标悬停事件

[英]VB.Net - Toolstrip Button Mousehover Event

Is there a way to change the size of the toolstrip button on mousehover event? 有没有办法在鼠标悬停事件上更改工具栏按钮的大小?
I tried this but didn't work. 我试过了,但是没用。

Private Sub tsDriver_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles tsDriver.MouseHover
    Dim pt As Point
    pt.X = 60
    pt.Y = 70
    tsDriver.Size = pt

End Sub

I'd like to have the effect like, when mouse is hovered on the button, it will grow big and when the mouse leaves it will go back to its original size. 我想要的效果是,当鼠标悬停在按钮上时,它将变大,而当鼠标离开时,它将恢复到其原始大小。

You should instantiate a the size, which is a separate object.Try this, it should work; 您应该实例化一个size,它是一个单独的对象。

Private Sub tsDriver_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles tsDriver.MouseHover

    Dim pt As New System.Drawing.Point 
    pt.X = 60
    pt.Y = 70
    tsDriver.Size = New System.Drawing.Size(pt)

End Sub

Note that the MouseHover event only triggers when the mouse cursor enters the control location. 请注意,仅当鼠标光标进入控件位置时,才会触发MouseHover事件。
So, for the button to shrink to original size, the MouseLeave event should be coded; 因此,为了使按钮缩小到原始大小,应该对MouseLeave事件进行编码;

Private Sub tsDriver_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles tsDriver.MouseLeave

    Dim pt As New System.Drawing.Point 
    pt.X = 40  ' Original size
    pt.Y = 50
    tsDriver.Size = New System.Drawing.Size(pt)
End Sub

Should only the button resize? 应该调整按钮的大小吗? or would it be okay for the rest of the buttons resize as well?? 还是其余的按钮也可以调整大小?

If so, you can Manipulate the ImageScalingSize property of the tool tip window 如果是这样,则可以操作工具提示窗口的ImageScalingSize属性。

       Dim pt2 As Point
       pt2.X = 100
       pt2.Y = 100

       ToolStrip1.ImageScalingSize = pt2

This assumes it's okay for the rest of the buttons to grow as well. 假设其余按钮也可以增长。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM