Results 1 to 12 of 12

Thread: [RESOLVED] tooltip problem

  1. #1

    Thread Starter
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Resolved [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:
    1. Private Sub lvwListing_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles lvwListing.MouseDown
    2.  
    3.         If optTerrName.Checked Then
    4.             Dim LVI As ListViewItem = lvwListing.GetItemAt(e.X, e.Y)
    5.             If LVI Is Nothing Then Return
    6.             If e.Button = MouseButtons.Right Then
    7.                 tipTerr.SetToolTip(lvwListing, LVI.Tag.ToString)
    8.                 tipTerr.Active = True
    9.             End If
    10.         End If
    11.  
    12.     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.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    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:
    1. Private Sub ListView1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
    2.     Dim lvwItem As ListItem
    3.     If Button = vbRightButton Then
    4.         Set lvwItem = ListView1.HitTest(x, y)
    5.         If Not lvwItem Is Nothing Then
    6.             lvwItem.Selected = True
    7.             PopUpMenu mnuFile
    8.         End If
    9.     End If
    10. End Sub
    Of course, I'm displaying a popupmenu, but you can easily susbstitute that with your tooltip.

  3. #3
    Fanatic Member
    Join Date
    May 2005
    Posts
    898

    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

  4. #4

    Thread Starter
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: tooltip problem

    Quote 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)

  5. #5
    Fanatic Member
    Join Date
    May 2005
    Posts
    898

    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

  6. #6
    Fanatic Member
    Join Date
    May 2005
    Posts
    898

    Re: tooltip problem

    here it is then
    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

  7. #7

    Thread Starter
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    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.

  8. #8
    Fanatic Member
    Join Date
    May 2005
    Posts
    898

    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

  9. #9
    Frenzied Member zaza's Avatar
    Join Date
    Apr 2001
    Location
    Borneo Rainforest Habits: Scratching
    Posts
    1,486

    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

  10. #10

    Thread Starter
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    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.

  11. #11
    Fanatic Member
    Join Date
    May 2005
    Posts
    898

    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

  12. #12

    Thread Starter
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    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
  •  



Click Here to Expand Forum to Full Width