Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

WinForms CheckedListBox control tooltip for items

Posted on 2006-07-08
5
Medium Priority
?
1,574 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
[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
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 2000 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

661 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