?
Solved

Help with displaing field definition when placing cursor on a row of a listbox using VB.NET

Posted on 2016-09-24
7
Medium Priority
?
34 Views
Last Modified: 2016-09-25
Hi,

When I place the cursor on a row of my listbox I need to display the defnition of the field, for example If I place my cursor on a row containing TV, would like too see a tooltip with the word television.

Thanks,

Victor
0
Comment
Question by:vcharles
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 63

Expert Comment

by:Fernando Soto
ID: 41814195
Hi Victor;

So where are you getting the "definition" to display in the tooltip?
0
 

Author Comment

by:vcharles
ID: 41814202
Hi Fernando,

I would like the hardcode the definition.

Thanks,

Victor
0
 
LVL 63

Accepted Solution

by:
Fernando Soto earned 2000 total points
ID: 41814239
Hi Victor;

Something like the following should work.
Public Class Form1

    Dim ttc1 As New ToolTip()

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        '' Items to be added to the ListBox
        Dim items As New List(Of MyListBoxItem)() From {New MyListBoxItem With {.Item = "NSN", .ToolTipValue = "NSN Value Here"},
            New MyListBoxItem With {.Item = "NSC", .ToolTipValue = "NSC Value Here"},
            New MyListBoxItem With {.Item = "FIF", .ToolTipValue = "FIF Value Here"}
        }

        ListBox1.DataSource = items
        ListBox1.DisplayMember = "Item"
        ListBox1.ValueMember = "ToolTipValue"

    End Sub

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        ttc1.SetToolTip(ListBox1, "Select an Item to see Description")
        ttc1.ShowAlways = True
    End Sub

    Private Sub ListBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListBox1.SelectedIndexChanged
        ttc1.SetToolTip(ListBox1, ListBox1.SelectedValue.ToString)
    End Sub

End Class

Public Class MyListBoxItem
    Public Property Item As String
    Public Property ToolTipValue As String

    Public Overrides Function ToString() As String
        Return Item
    End Function
End Class

Open in new window

0
Certified OpenStack Administrator Course

We just refreshed our COA course based on the Newton exam.  With 14 labs, this course goes over the different OpenStack services that are part of the certification: Dashboard, Identity Service, Image Service, Networking, Compute, Object Storage, Block Storage, and Orchestration.

 

Author Comment

by:vcharles
ID: 41814256
Hi Fernando,

Thanks for the code. How do you modify it to work when I place the mouse on the row? not select the row.

Thanks,

Victor
0
 
LVL 63

Expert Comment

by:Fernando Soto
ID: 41814270
You can't because the ToolTip control is attached to a control and not to a collection.
0
 

Author Comment

by:vcharles
ID: 41814286
Ok. Thanks.
0
 
LVL 63

Expert Comment

by:Fernando Soto
ID: 41814621
Not a problem Victor, glad to help.
0

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question