Solved

WinForms CheckedListBox control tooltip for items

Posted on 2006-07-08
5
1,520 Views
Last Modified: 2012-06-27
Does anyone know how to set the tooltip for a CheckedListBox item?

I have a bunch of items in my checked list box, and some of the item display names are too wide for the checked list box.

I would like the user to be able to see the entire text of the item in a tooltip.

Thanks!
0
Comment
Question by:gregasm
5 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 17067871
Attempt #1:

  Private Sub CheckedListBox1_MouseMove(ByVal sender As System.Object, ByVal e As MouseEventArgs) Handles CheckedListBox1.MouseMove

    Dim topIndex As Integer = Me.CheckedListBox1.TopIndex
    Dim itemHeight As Integer = Me.CheckedListBox1.ItemHeight
    Dim index As Integer = (e.Y \ itemHeight) + topIndex
    Dim itemText As String = Me.CheckedListBox1.Items(index)

    If Me.ToolTip1.GetToolTip(Me.CheckedListBox1) <> itemText Then
      Me.ToolTip1.SetToolTip(Me.CheckedListBox1, itemText)
    End If

  End Sub

Bob
0
 
LVL 18

Expert Comment

by:Ravi Singh
ID: 17067873
Hi, one approach would be to handle the CheckedListBox's SelectedIndexChanged event, then set the tooltop of the entire control to whats currently selected:

private void checkedListBox1_SelectedIndexChanged(object sender, System.EventArgs e)
{
      this.toolTip1.SetToolTip(this.checkedListBox1, this.checkedListBox1.Text);
}

(Drag a tooltop onto your form from the toolbox, it should declare it automatically for you in the code editor)
0
 
LVL 8

Author Comment

by:gregasm
ID: 17068895
A tooltip should not require a selection changed event, only a mouse hover. I like Bob's idea and i think it is going in the right direction, but the entire scenario becomes more involved when we try to use the mouse hover event, and then have to handle clearing the tooltip as well as showing it...

I will try out the samples and see if it gets me anywhere.

Of course, the other solution is to just not do the entire thing if the scope starts to grow too big.
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 500 total points
ID: 17068968
If you want to use the MouseHover event, then you need to store the current Point, and use that in the MouseHover event, since it doesn't have that information as arguments.

Bob
0
 

Expert Comment

by:dastaub
ID: 37067944
i used the first suggestion and it worked flawlessly.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

708 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now