Setting the text for a tooltip where the object that it is a tooltip for has changed its value

I've got 4 linklabels, when I click on each of them, their value changes. When I hover my mouse over any of the linklabels, my tooltip appears. For each linklabel the value of the tooltip is different. Visual Basic Express Edition 2005 refers to this as "ToolTip on tltp_name".

The problem is that, once any of the linklabels' values have changed, when I hover my mouse over them, the previous tooltip shows. I want a totally different tooltip to show.

Three things complicate this for me:

1. ToolTips don't have a text property.

2. You can't (or atleast I haven't been able to)  initiate the onclick event within the design mode (so that I could assign a different ToolTip on tltp_name for the changed value.

3. ToolTip on tltp_name creates errors when I try to use it in code.



Answer this question

Setting the text for a tooltip where the object that it is a tooltip for has changed its value

  • mina_mina

    I've actually managed to solve my problem myself, using the following line of code within a sub handling a linklabel.click event.

    tltp_tooltip.Show("Different text", lnklbl_linklabel)

    This combined with the ToolTip on tltp_name works well.

    But when the linklabel is clicked the tooltip shows instantly. Is there some way I can delay it


  • JimDan

    Doing it in the click event is somewhat defeating th original purpose of the tooltip not requiring you to click the control - just however over it.

    I'd look at the sample I gave and you'll see how easy it is to use the tooltips in the correct way - once you know you'll see how easy it is and then you have control over how delays using the tooltip control.


  • vjnfjvbnhjbvgfb

    Heres a simple example, I've wrapped the changing of the linklabel text and tooltip in a single method. The tooltip control is an extender which means it extends the properties of the other controls on the forms but it doesnt have direct access to modify the originally control so its a bit of an illusion

    Really a good way to think about what its doing is its maintaining a collection of properties with a reference to each of the controls.

    So in this case you go to the tooltip control and use the settooltip method and tell it which control you want to update the tooltip on and what the new tooltip is.

    Its really pretty damn easy when you know how it works.

    Public Class Form1
    Private Sub ChangeLinkLabel(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    UpdateLinkLabel(ToolTip1, LinkLabel1, "test changed text", "test changed tooltip")
    UpdateLinkLabel(ToolTip1, LinkLabel2, "test XYZ TEST", "test XYZ Changed tooltip")

    End Sub

    Sub UpdateLinkLabel(ByRef TooltipControl As ToolTip, ByRef Control1 As LinkLabel, ByVal NewText As String, ByVal tooltiptext As String)
    'Change the tooltip on LinkLabel
    Control1.Text = NewText
    TooltipControl.SetToolTip(Control1, tooltiptext)
    End Sub
    End Class


  • RayCh

    With a little bit more determination and exploration, I managed to solve my own problem as shown below:

    Before:

    tltp_tooltip.Show("Different text", lnklbl_linklabel)

    After:

    tltp_all.Hide(lnklbl_linklabel)
    tltp_tooltip.Show("Different text", lnklbl_linklabel)

    That way it doesn't show straight away.


  • Dan Kahler

     ampersandz wrote:

    1. ToolTips don't have a text property.

    2. You can't (or atleast I haven't been able to) initiate the onclick event within the design mode (so that I could assign a different ToolTip on tltp_name for the changed value.

    3. ToolTip on tltp_name creates errors when I try to use it in code.



    You set the ToolTip text property to the control (which you want to view the tooltip for it).
    For 2, I think I don't understand you, you can put a code when the ToolTip Disposed, Draw or PopUp, if you want to show two different tooltips, you can put 2 in the design-time, then set the control properties for them, for example "ToolTip On ToolTip1" and "ToolTip On ToolTip2", then you can show and hide them by using ToolTip.Active property...
    Hope this helps you a bit.



  • Setting the text for a tooltip where the object that it is a tooltip for has changed its value