Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

hi ....

 

i have 14 buttons with 14 tool tip names taken from an array soundname(13)

 

so when i mouse over i run this

 

 

Code:

Private Sub btnSdOne_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSdOne.MouseHover

Dim tooltip1 As New ToolTip

tooltip1.SetToolTip(btnSdOne, SoundsName(0))

End Sub

 

 

 

witch is fine untill you change the setting of the sound name (witch you can in the setup menu)

 

then the last value is still there for one second then it shows the new value

 

and same if you change it for a third time

 

you mouse over then the tool tip

 

will show first value wait a second then show last value wait a second then show new value

 

whats going on all i want it to do is show the new value all the time

 

i tried putting in a small sub that reads the array again b4 it shows the tool tip but that doesn't work either

 

 

thanks in advance

  • *Experts*
Posted (edited)

Try using the controls enter and leave subs instead of the mouse hover. It would also be easier if you used a 2D array with the control name being on the first index and the tooltip being the other.

ie:

SoundsName(0, 0) = "btnSdOne"

SoundsName(0, 1) = "controls tooltip"

etc.

 

Sample using 1D array:

Private Sub Show_ToolTips(ByVal sender As Control, , ByVal e As System.EventArgs) Handles _
btnSdOne.MouseEnter ', and all the buttons here

ToolTip1.Active = True
Dim ctrl as Control = DirectCast(sender, Control)
Dim idx as Integer
If ctlr Is btnSdOne Then idx = 0
'add other control array indexes here
ToolTip1.SetToolTip(ctrl, SoundsName(idx)) 

End Sub

 

Sample using 2D array

Private Sub Show_ToolTips(ByVal sender As Control, , ByVal e As System.EventArgs) Handles _
btnSdOne.MouseEnter ', and all the buttons here

ToolTip1.Active = True
Dim ctrl as Control = DirectCast(sender, Control)
For Each ctrl in Me.Controls
   For i As Integer = 0 to Me.Controls.Count - 1
       If ctrl.Name = SoundsName(i, 0) Then
           ToolTip1.SetToolTip(ctrl, SoundsName(i, 1)) 
            Exit For
       End If
   Next
Next
End Sub

 

Then hide the tooltips by de-activating ToolTip1 in the controls Leave sub

Private Sub Hide_ToolTips(ByVal sender As Control, , ByVal e As System.EventArgs) Handles _
btnSdOne.MouseLeave ', and all the buttons here

ToolTip1.Active = False

End Sub

 

Another thought is to abandon the tool tip array and directly set the control tool tips in the appropriate sub. Then in the Show_ToolTips - mouse enter sub simply activate the tool tip after setting its parent control (ctrl). As this does not require and loops it would be faster...but probably not noticeably.

Edited by DiverDan

Member, in good standing, of the elite fraternity of mentally challenged programmers.

 

Dolphins Software

Posted
Sample using 2D array

 Private Sub Show_ToolTips(ByVal sender As Control, , ByVal e As System.EventArgs) Handles _
btnSdOne.MouseEnter ', and all the buttons here

ToolTip1.Active = True
Dim ctrl as Control = DirectCast(sender, Control)
For Each ctrl in Me.Controls
   For i As Integer = 0 to Me.Controls.Count - 1
       If ctrl.Name = SoundsName(i, 0) Then
           ToolTip1.SetToolTip(ctrl, SoundsName(i, 1)) 
            Exit For
       End If
   Next
Next
End Sub

 

Hashtables anyone? key=control's name (I'd have to play with it but I think that would work), value=tool tip. No looping required.

 

If there's still flicker, I agree with DiverDan's last comment about setting the tool tips individuall instead of using an array.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...