我想知道是否有办法在鼠标悬停事件中为Visual Studio Community 2013中的表单按钮创建图像工具提示。
理想情况下,只要光标位于按钮上方,图像就会在光标上方不断显示,并随光标移动。
我猜我不能使用Tooltip对象,因为我已经研究过了,所以我想知道怎么回事。
答案 0 :(得分:2)
Try placing the ToolTip component on your form and a button control:
Protected Overrides Sub OnLoad(e As EventArgs)
MyBase.OnLoad(e)
ToolTip1.OwnerDraw = True
ToolTip1.SetToolTip(Button1, "This is a tool tip message for the button.")
End Sub
Private Sub ToolTip1_Popup(sender As Object, e As PopupEventArgs) Handles ToolTip1.Popup
e.ToolTipSize = New Size(200, 64)
End Sub
Private Sub ToolTip1_Draw(sender As Object, e As DrawToolTipEventArgs) Handles ToolTip1.Draw
e.Graphics.Clear(SystemColors.Info)
e.Graphics.DrawImage(SystemIcons.Application.ToBitmap(), New Point(16, 16))
TextRenderer.DrawText(e.Graphics, e.ToolTipText, e.Font, _
New Rectangle(64, 8, e.Bounds.Width - 72, e.Bounds.Height - 16), _
SystemColors.InfoText, Color.Empty, _
TextFormatFlags.WordBreak Or TextFormatFlags.VerticalCenter)
End Sub
Result:
答案 1 :(得分:0)
you could start here. It provides ToolTipImage property:
http://www.codeproject.com/Articles/98967/A-ToolTip-with-Title-Multiline-Contents-and-Image