|
-
Aug 22nd, 2005, 09:25 AM
#1
[RESOLVED] tooltip problem
Ok, wondering if anyone can shed some light on this one for me.
I have a listview (details view) that when you right click on a listviewitem, a tooltip pops up with some additional information. Here is the code I use
VB Code:
Private Sub lvwListing_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles lvwListing.MouseDown
If optTerrName.Checked Then
Dim LVI As ListViewItem = lvwListing.GetItemAt(e.X, e.Y)
If LVI Is Nothing Then Return
If e.Button = MouseButtons.Right Then
tipTerr.SetToolTip(lvwListing, LVI.Tag.ToString)
tipTerr.Active = True
End If
End If
End Sub
Now the problem is that the first time a user right clicks an item, the tooltip is not shown. If they right click on an item, and then right click it again, it does work. Also any right clicks after that also work fine, its just the first one. I assue it has something to do with focus or something, but what is odd is when I put a break point, on the first click all the code runs, including the settooltip and active = true parts, so I don't know why the tip does not display. Any ideas? I have already tried various things like manually calling the focus event of the listview at the start of the above routine, also setting the selected and focused properties to true for the listviewitem prior to the tip display. Also I tried setting the ShowAlways property of the tooltip to true. None change the way its working.
-
Aug 22nd, 2005, 09:34 AM
#2
Re: tooltip problem
With a Listview, like a listbox, the item has to be selected first (which, by default, the right mouse button does not do). Here is what I use in VB6. Translating it into .NET shouldn't be that difficult.
VB Code:
Private Sub ListView1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim lvwItem As ListItem
If Button = vbRightButton Then
Set lvwItem = ListView1.HitTest(x, y)
If Not lvwItem Is Nothing Then
lvwItem.Selected = True
PopUpMenu mnuFile
End If
End If
End Sub
Of course, I'm displaying a popupmenu, but you can easily susbstitute that with your tooltip.
-
Aug 22nd, 2005, 10:25 AM
#3
Fanatic Member
Re: tooltip problem
Kleinma,
I have tested your code, and it works for me. Of course I commented out the check on optTerrName.Checked because I do not have that object in my project. The tooltip appears after right-clicking a listviewitem(regardless of focus), ofcourse it keeps reapearing because it remains active, but I assume that you are deactivating it somewhere.
Could it be that some other part of your code is causing this?
"so just keep in mind that fantasy is not the same as realtiy and make sure u remember that wii sports may be fun but u cant count on it as exercise ok cool bye" - HungarianHuman
-
Aug 22nd, 2005, 11:34 AM
#4
Re: tooltip problem
 Originally Posted by grilkip
Kleinma,
I have tested your code, and it works for me. Of course I commented out the check on optTerrName.Checked because I do not have that object in my project. The tooltip appears after right-clicking a listviewitem(regardless of focus), ofcourse it keeps reapearing because it remains active, but I assume that you are deactivating it somewhere.
Could it be that some other part of your code is causing this?
could you post the project that you did this test in? I would be interested to see it... I don't think there is anything else in my code that could be doing it... the whole optTerrName thing should not be a factor (I just commented it out and it still acts the same)
-
Aug 22nd, 2005, 12:15 PM
#5
Fanatic Member
Re: tooltip problem
Well ok, its just an empty project with a listview with some items added at design time, but I'll post it in a minute
"so just keep in mind that fantasy is not the same as realtiy and make sure u remember that wii sports may be fun but u cant count on it as exercise ok cool bye" - HungarianHuman
-
Aug 22nd, 2005, 12:21 PM
#6
Fanatic Member
Last edited by grilkip; Dec 16th, 2007 at 11:29 AM.
"so just keep in mind that fantasy is not the same as realtiy and make sure u remember that wii sports may be fun but u cant count on it as exercise ok cool bye" - HungarianHuman
-
Aug 22nd, 2005, 01:02 PM
#7
Re: tooltip problem
I tested your app.. but it has the same results as my original problem. So either you didn't notice, or (hopefully not) its something with my system.
Try this... load your app in VS and run it. Don't click ANYTHING at all, just right click the first listitem. It does NOT display the tooltip... all right clicks after (either on the same listitem, or a new one) display the correct tip.
-
Aug 22nd, 2005, 01:11 PM
#8
Fanatic Member
Re: tooltip problem
I swear on RobDogg888's eyes, it works.
I click the 'play' button in VS, I wait for the form to appear and I right-click the first listviewitem. Shortly, a tooltip appears. Scouts honor.
"so just keep in mind that fantasy is not the same as realtiy and make sure u remember that wii sports may be fun but u cant count on it as exercise ok cool bye" - HungarianHuman
-
Aug 22nd, 2005, 01:22 PM
#9
Re: tooltip problem
Hi,
I've had "similar" problems in the past. Not with tooltip specifically, but with other code which appears to execute perfectly well, but just doesn't then do what it is supposed to. For example, I have a "Help" push button on a toolbar to pull context-sensitive topics from my chm file. And sometimes, mysteriously, it just doesn't work. And then, after closing and reloading the project, it'll be back.
Also, my splash screen sometimes fails to disappear even though I've put traps in the code for it.
Another bugbear is that sometimes I find that the AxRichText Interop (for my VB6 RTBs) just removes itself from the references and decides that it can't be found. But I can navigate to the OCX and put it back, and it'll be fine.
So it's not just you, kleinma, but it may be your system.
zaza
-
Aug 22nd, 2005, 01:27 PM
#10
Re: tooltip problem
wait... ok grilkip, I see what you are saying... it works the same on mine too.
I guess my problem is this then:
why does the first tip take x amount of seconds to show, but all right clicks after show the tip right away. I want that functionality on the first click as well.
-
Aug 22nd, 2005, 01:38 PM
#11
Fanatic Member
Re: tooltip problem
OMG then say so! 
I'm not sure you can really get what you want, when I set all the delay-properties to zero, there is still an initial delay. The tooltip really isn't well adjustable at all. bummer
"so just keep in mind that fantasy is not the same as realtiy and make sure u remember that wii sports may be fun but u cant count on it as exercise ok cool bye" - HungarianHuman
-
Aug 22nd, 2005, 01:42 PM
#12
Re: tooltip problem
I created a work around by pretty much running the same code before the user does anything (like form load) I do
tipTerr.SetToolTip(lvwListing, LVI.Tag.ToString)
tipTerr.Active = True
since i cant get a listviewitem via the X/Y coords, I simply use the first item in the list. It doesn't display a tooltip unless u mouse over the listview, and then on first right click it displays the tooltip right away like the rest.
Thanks for the time u took too look at it.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|