HighTechTalks DotNet Forums  

Need help programatically creating a tool tip

VB.net Controls microsoft.public.dotnet.languages.vb.controls


Discuss Need help programatically creating a tool tip in the VB.net Controls forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
The Mad Ape
 
Posts: n/a

Default Need help programatically creating a tool tip - 04-05-2008 , 09:41 PM






Hi

I have code to problematically create a label. It works but when I try
to call a sub to create a tooltip it does not work. I do not get an
error so have no idea what it wrong. Please review my code and tell me
how to fix it.

Thanks

The Mad Ape
www.tatumba.com

CODE TO CREATE LABEL:

Dim tabLblPulp As New Label
tabLblPulp.Location = New Point(14, 121)
tabLblPulp.Size = New Size(54, 13)
tabLblPulp.Name = tp.Text & "lblPulpwood"
tabLblPulp.Text = "Pulpwood"
tabLblPulp.ForeColor = Color.Blue
tabLblPulp.Visible = True
tabLblPulp.Font = New System.Drawing.Font("Microsoft
Sans Serif", 8.25!, System.Drawing.FontStyle.Underline,
System.Drawing.GraphicsUnit.Point, CType(0, Byte))
tp.Controls.Add(tabLblPulp)

'code to call sub

AddHandler tabLblPulp.Click, AddressOf ToolTiper

Public Sub ToolTiper(ByVal sender As Object, ByVal e As EventArgs)

Dim ctrlName As String
ctrlName = DirectCast(sender, Control).Name()
Dim ToolTip2 As New ToolTip
Dim ctrl As Control
For Each ctrl In Form7.Controls
If ctrl.Name = ctrlName Then
ToolTip2.SetToolTip(ctrl, "Test")
End If
Next

End Sub

Reply With Quote
  #2  
Old   
David Griffiths
 
Posts: n/a

Default Re: Need help programatically creating a tool tip - 04-09-2008 , 01:30 AM






Hi

You say your label works great.

The code below works on my VB 2008. I adeded a label to Form1 and named it
accordingly. You have your tooltip showing when you click the control
normally a tooltip shows on hover as my code demonstartes.

I had to change your reference to Form7 to "Me" as I only had the one form
in the project. If the code is on the same form remember to use ME instead
of the formName

Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

AddHandler tabLblPulp.MouseHover, AddressOf ToolTiper

End Sub


Public Sub ToolTiper(ByVal sender As Object, ByVal e As EventArgs)

Dim ctrlName As String
ctrlName = DirectCast(sender, Control).Name()
Dim ToolTip2 As New ToolTip
Dim ctrl As Control
For Each ctrl In Me.Controls
If ctrl.Name = ctrlName Then
ToolTip2.SetToolTip(ctrl, "This Code Works")
End If
Next

End Sub

--
DaveG

"The Mad Ape" <chiefape (AT) gmail (DOT) com> wrote

Quote:
Hi

I have code to problematically create a label. It works but when I try
to call a sub to create a tooltip it does not work. I do not get an
error so have no idea what it wrong. Please review my code and tell me
how to fix it.

Thanks

The Mad Ape
www.tatumba.com

CODE TO CREATE LABEL:

Dim tabLblPulp As New Label
tabLblPulp.Location = New Point(14, 121)
tabLblPulp.Size = New Size(54, 13)
tabLblPulp.Name = tp.Text & "lblPulpwood"
tabLblPulp.Text = "Pulpwood"
tabLblPulp.ForeColor = Color.Blue
tabLblPulp.Visible = True
tabLblPulp.Font = New System.Drawing.Font("Microsoft
Sans Serif", 8.25!, System.Drawing.FontStyle.Underline,
System.Drawing.GraphicsUnit.Point, CType(0, Byte))
tp.Controls.Add(tabLblPulp)

'code to call sub

AddHandler tabLblPulp.Click, AddressOf ToolTiper

Public Sub ToolTiper(ByVal sender As Object, ByVal e As EventArgs)

Dim ctrlName As String
ctrlName = DirectCast(sender, Control).Name()
Dim ToolTip2 As New ToolTip
Dim ctrl As Control
For Each ctrl In Form7.Controls
If ctrl.Name = ctrlName Then
ToolTip2.SetToolTip(ctrl, "Test")
End If
Next

End Sub


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.