|
-
Nov 14th, 2010, 01:06 PM
#1
Thread Starter
Junior Member
Popup message when mousehover a label
Hello everybody.
I am new to VB and need some help.
I have created some labels and i need them to display a popup message when you hover the mouse over them at runtime. I searched for a solution but i only found out how to display popups when hovering over a button and also the code for that was overly complicated. Any ideas?
Thanks a lot.
-
Nov 14th, 2010, 01:22 PM
#2
Re: Popup message when mousehover a label
try this:
vb Code:
Public Class Form1
Dim tt As ToolTip
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
tt = New ToolTip
tt.SetToolTip(Label1, "message")
End Sub
End Class
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Nov 14th, 2010, 01:36 PM
#3
Thread Starter
Junior Member
Re: Popup message when mousehover a label
Wow thanks a lot. It worked, i only had to change the event to MouseHover..
-
Nov 14th, 2010, 01:39 PM
#4
Re: Popup message when mousehover a label
 Originally Posted by 16horse
i only had to change the event to MouseHover..
no need. it will work if you call settooltip in form_load + it'll only do it once, instead of every time your mouse hovers on the label
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Nov 15th, 2010, 08:42 AM
#5
Thread Starter
Junior Member
Re: Popup message when mousehover a label
Another question. Is there a way to create a module out of this code in order to display different messages when i hover over different label?So that i write the code once and use it for all the different labels and their individual popup messages.
-
Nov 15th, 2010, 09:19 AM
#6
Re: Popup message when mousehover a label
16horse, all you need to do is add a ToolTip component to your form and you'll be able to set the ToolTip text on all the visual controls you want to on that form. There's no need for something like this to be ran through a module.
-
Nov 15th, 2010, 09:23 AM
#7
Re: Popup message when mousehover a label
it's simple to set a tooltip for any number of controls:
vb Code:
Public Class Form1
'declare tooltip at form level
Dim tt As ToolTip
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'initialize tt with 'New' keyword
tt = New ToolTip
'set tooltip for any control here
'don't put this in the mousehover event,
'or it'll keep running this code every time it fires
tt.SetToolTip(Label1, "message1")
tt.SetToolTip(Label2, "message2")
End Sub
End Class
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Nov 15th, 2010, 09:50 AM
#8
Thread Starter
Junior Member
Re: Popup message when mousehover a label
I managed to do it on my own, finally, but with a messier code than .paul. suggested. So i changed it with yours and it works.
Thanks again soooo much.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|