Solved

WinForms CheckedListBox control tooltip for items

Posted on 2006-07-08
5
1,526 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
C# Error - Add Failed 12 78
Visual Studio TFS - how do I check in my code? 2 29
Capture logon name 13 42
Web Form VB.Net  import CSV 4 26
Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

895 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

13 Experts available now in Live!

Get 1:1 Help Now