Click here to Skip to main content
16,017,788 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi experts,

I'm new to vb.net. I'm using a button to expand/collapse a panel. This button is used to show/hide a panel contains some other buttons. I want to have a tooltip to show "Expand Panel" when panel hides and "Collapse Panel" when the panel shown.

Below is the code which I tried out.

VB
Private Sub Expand_MouseHover(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button.MouseHover
       Dim toolTip As New ToolTip()
       toolTip.SetToolTip(Me.Button, "")

       If Not Me.Expanded Then
           toolTip.SetToolTip(Me.Button, "Expand")
       Else
           toolTip.SetToolTip(Me.Button, "Collapse")
       End If
   End Sub


The problem now is the tooltip text are overlapping each other if hover over the button. And sometimes we can see the text "Expand Panel" before it change to "Collapse Panel".

Anyone have suggestion on this?

Advanced thanks,
Skundhead

[Removed fake c# tag]
Posted
Updated 11-Nov-10 2:54am
v3

1 solution

How about:
VB
Private Sub Expand_MouseHover(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button.MouseHover
    Dim toolTip As New ToolTip()
    toolTip.SetToolTip(Me.Button, "")
    If Not Panel1.Visible = True Then
        toolTip.SetToolTip(Me.Button, "Expand")
    Else
        toolTip.SetToolTip(Me.Button, "Collapse")
    End If
End Sub
 
Share this answer
 
Comments
Dalek Dave 11-Nov-10 3:48am    
Good Answer.
skunkhead 22-Dec-10 23:21pm    
thanks Scubapro

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900