开发者

How Can I Create a Mouseover Tooltip on an Image in VB.NET?

开发者 https://www.devze.com 2023-01-22 09:58 出处:网络
Can I create a tooltip that will show up when a user moves his/her cursor over an image? I can\'t find such a property in Visual Studio, and I\'ve scoured Google to no avail. I\'m using an image in a

Can I create a tooltip that will show up when a user moves his/her cursor over an image? I can't find such a property in Visual Studio, and I've scoured Google to no avail. I'm using an image in a PictureBox.

Here's to anyone out there on StackOve开发者_如何学JAVArflow instead of some awesome Halloween party! Yay!


yea, for some reason the Picturebox doesnt have one.


imports System.Drawing


dim tt as new ToolTip()
tt.SetToolTip(picPicture, "This is a picture") 

and dont worry, the weekend has only started, plenty of time to party.


Typically I create the interface then throw a ToolTip object from the Toolbox on to the form.

How Can I Create a Mouseover Tooltip on an Image in VB.NET?

This then gives each object the "ToolTip" property (towards the bottom of the list) which can then be configured to your delight.

How Can I Create a Mouseover Tooltip on an Image in VB.NET?


Drag a ToolTip control from the toolbox on the left onto your form (the designer will then put it below your form, since it's not meant to be visible normally). By default it will be named "tooltip1".

Then select your checkbox and go over to its properties window. You should see a property labeled "Tooltip on tooltip1" - set this to whatever you want. When you run the app and hold the mouse over your checkbox, you should see the tooltip text.


Assuming that you have added a picture box member with the WithEvents modifier you can use the following

Private tt As ToolTip = New ToolTip()

Sub OnPictureMouseHover(ByVal sender As Object, ByVal e As EventArgs) Handles PictureBox1.MouseHover
    tt.Show("the message", Me)
End Sub

Sub OnPictureMouseLeave(ByVal sender As Object, ByVal e As EventArgs) Handles PictureBox1.MouseLeave
    tt.Hide()
End Sub
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号