• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 204
  • Last Modified:

Creating tooltips

Below is the code i am using to create labels on runtime, my question is how can i add tooltips to these labels?

Dim sectortime As DateTime
Dim sectors(250) As Label
Dim sectip As ToolTip
Dim seclength As Integer
Dim secposition As Integer
Dim sectorto As String

With sectors(currentlabelnumber)
                                .Left = secposition + seclength - 5
                                .Top = 131 + (k * 182 - 150 + value)
                                .Text = sectorto
                                .AutoSize = True
                                .BorderStyle = BorderStyle.FixedSingle
                            End With
 sectip.SetToolTip(Me.sectors(currentlabelnumber), sectortime)

                            currentlabelnumber = currentlabelnumber + 1

As you can see i have tried adding a tooltip, but on runtime i am informed that object refrence not set to an instance of an object.

Any help is much appreciated.
  • 3
1 Solution
Éric MoreauSenior .Net ConsultantCommented:
Hi dr_dudd,

You need to add a ToolTip component to your form and call ToolTip1.SetToolTip(YourControlName, "Your tip")

Éric MoreauSenior .Net ConsultantCommented:
dr_duddAuthor Commented:
Hi emoreau

I have already tried this.... if you look closely at the code in the question you will already see the lines...

Dim sectip As ToolTip

sectip.SetToolTip(Me.sectors(currentlabelnumber), sectortime)

                sectip= New ToolTip
                sectip.SetToolTip(Me.sectors(currentlabelnumber), sectortime.ToString)
                sectip.Active = True
Éric MoreauSenior .Net ConsultantCommented:

but I don't think that your Tooltip as you defined it belongs to the form so the form cannot show it! Try adding a Tooltip component and use that one.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now