views:

2171

answers:

4

I am trying to set the tool tip text for some of my subitems in my listview control. I am unable to get the tool tip to show up.

Anyone have any suggestions?

Private _timer As Timer
Private Sub Timer()
    If _timer Is Nothing Then
        _timer = New Timer
        _timer.Interval = 500
        AddHandler _timer.Tick, AddressOf TimerTick
        _timer.Start()
    End If
End Sub
Private Sub TimerTick(ByVal sender As Object, ByVal e As EventArgs)
    _timer.Enabled = False
End Sub

Protected Overrides Sub OnMouseMove(ByVal e As System.Windows.Forms.MouseEventArgs)
    If Not _timer.Enabled Then
        Dim item = Me.HitTest(e.X, e.Y)
        If Not item Is Nothing AndAlso Not item.SubItem Is Nothing Then
            If item.SubItem.Text = "" Then
                Dim tip = New ToolTip
                Dim p = item.SubItem.Bounds
                tip.ToolTipTitle = "Status"
                tip.ShowAlways = True
                tip.Show("FOO", Me, e.X, e.Y, 1000)
                _timer.Enabled = True
            End If
        End If
    End If

    MyBase.OnMouseMove(e)
End Sub
+3  A: 
Grammarian
Thanks for the suggestions. I would rather not use a control since this is the only thing left I need to do for my listview control.Is there a tutorial or example on how to "listen for WM_NOTIFY messages" ? Thanks
Just download the code for ObjectListView and have a look at WndProc() in ObjectListView.cs.
Grammarian
will do thanks!
I think I got it working except for one line.Dim ttt As TOOLTIPTEXT = DirectCast(m.GetLParam(GetType(NativeMethods.TOOLTIPTEXT)), NativeMethods.TOOLTIPTEXT) I did not see TOOLTIPTEXT in the NaticeMethods class.
figured it out. Thanks for the help!
+1  A: 

Assuming .NET 2.0 or later, you can also set ListView.ShowItemToolTips to true. If you need to customize the tooltip text for a given item, set ListViewItem.ToolTipText to the string you want displayed.

Andy
A: 

Hi ryan really keen to get this to work. I know this is old but any chance that you could post up the working vb source code for your working version.

Thanks Liam

Liam
A: 

If you set ShowItemTooltips for the ListView control in "details" mode and do nothing else, the ListView control will automatically provide tooltips for items and subitems that exceed their column's widths. This turns out to work even if the FullRowSelect property is set to true. If ToolTipText has been set for a ListViewItem and FullRowSelect is true, then the tooltip will appear for the whole row; that's the case where tooltips won't be displayed for subitems.

sunil