4

I am using win form's list box control.

I want to add tool tips on list items. I could not find any default such properties.

Please share me , how can i add tool tips on winform list box items ?

Thank You

dsi
  • 3,199
  • 12
  • 59
  • 102

4 Answers4

2

If you want to do it in a listbox you will need to do it manually. Add a tooltip to the form and update the tooltip based on the mouses postion. An easier way to do this might be to use a DataGridView control like this:

    DataGridView1.RowHeadersVisible = False
    DataGridView1.ColumnHeadersVisible = False
    DataGridView1.Columns(0).AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCellsExceptHeader
    Dim mydata As String() = {"Item 1", "Item 2", "Item 3", "Item 4", "Item 5", "Item 6"}
    For Each dataitem As String In mydata
        DataGridView1.Rows.Add(dataitem)
    Next
    For Each row As DataGridViewRow In DataGridView1.Rows
        row.Cells(0).ToolTipText = "ToolTip for " & row.Cells(0).Value
    Next row
adrianwadey
  • 1,719
  • 2
  • 11
  • 17
2

I able to resolve thorough below ways:

'tooltip
Dim toolTip As ToolTip = New ToolTip()
    Private Sub lstReports_MouseMove(sender As Object, e As MouseEventArgs) Handles lstReports.MouseMove
    Dim index As Integer = lstReports.IndexFromPoint(e.Location)
    If (index <> -1 AndAlso index < lstReports.Items.Count) Then
        If (toolTip.GetToolTip(lstReports) <> lstReports.Items(index).ToString()) Then
            toolTip.SetToolTip(lstReports, lstReports.Items(index).ToString())
        End If
    End If
End Sub

one ref link:

http://dotnetfollower.com/wordpress/2012/01/winforms-show-individual-tooltip-for-each-listbox-item/ Thanks

dsi
  • 3,199
  • 12
  • 59
  • 102
  • Thanks! This works great, but is there any way to change the duration that the tooltip display. I can't read the entire text before it disappears. – Superdooperhero Nov 13 '19 at 20:31
  • toolTip.AutoPopDelay=7000 ' duration in mS. You might also want to set InitialDelay - how fast it shows, and ReshowDelay - how long, after it hides, before it will be shown again, – PolicyWatcher Feb 14 '21 at 11:14
2

I thought I'd mention that there is a ShowItemToolTips boolean attribute on ListView, if you want to use that instead of a ListBox. Set that attribute to true and then assign the ToolTipText values on the ListView items.

Koopakiller
  • 2,838
  • 3
  • 32
  • 47
1

Sadly, there is no implemented way to show ToolTips on each individual ListBox Item.

You can create your own ListBox control that allows you to do that, like this one: http://www.codeproject.com/Articles/457444/Listbox-Control-with-Tooltip-for-Each-Item

SysDragon
  • 9,692
  • 15
  • 60
  • 89