Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm Controls / February 2005

Tip: Looking for answers? Try searching our database.

Tooltip problem in TabControl

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Sholto Douglas - 24 Feb 2005 03:59 GMT
I have created a form containing Messenger-style owner-draw TabControl, with
the tabs down the left side.
I have found that the tooltips in the top/first tab page work fine when I
first start up the program (this is the 'default' page that is first
displayed).
However, if I click on any other tab pages, then go back to the first, the
tooltips no longer display.  It only affects the first page.
I have output trace messages of the tooltip contents (with
toolTip.GetToolTip()), and the tooltip contains the correct text - it just
won't display it!  All the tab pages are derived from a base class which
contains and instantiates the tooltip object, so the code to create and
activate it is the same in all pages.
The tooltip text is added dynamically (i.e not at design time).
I tried googling for a solution, but the only one I found suggested holding
down the SHIFT key.  It didn't work!

Any ideas?
Signature

Cheers,
Sholto Douglas
CyTrack Telecommunications
http://www.cytrack.com.au

Mick Doherty - 24 Feb 2005 11:50 GMT
How are you setting the tooltiptext?
Have you added your own tooltip class to your custom tabpage or are you
using the built in tooltip?

Signature

Mick Doherty
http://dotnetrix.co.uk/nothing.html

>I have created a form containing Messenger-style owner-draw TabControl,
>with
[quoted text clipped - 15 lines]
>
> Any ideas?
Sholto Douglas - 25 Feb 2005 02:11 GMT
> How are you setting the tooltiptext?

   toolTip.SetToolTip(listBox,sTooltip);
where listBox is the control over which it is hovering, and sTooltip is the
string to be displayed

> Have you added your own tooltip class to your custom tabpage or are you
> using the built in tooltip?

I have added my own tooltip because the contents of the tooltip change
according to the line the cursor is hovering over.  I cannot set it at design
time for this reason.  As I said, it works fine for all tab pages except the
'top' one.

> How are you setting the tooltiptext?
> Have you added your own tooltip class to your custom tabpage or are you
> using the built in tooltip?
Mick Doherty - 25 Feb 2005 12:02 GMT
So it's not the tabcontrols tooltip, but a control on the tabpage that is
showing the error.

The following code showed no such problem on my machine:
\\\
private void listBox1_MouseMove(object sender, MouseEventArgs e)
{
   Object HotItem = null;
   for (int index = 0;  index < listBox1.Items.Count; index++)
   {
       if (listBox1.GetItemRectangle(index).Contains(e.X, e.Y))
           HotItem = listBox1.Items[index];
   }

   if (HotItem == null)
       toolTip1.SetToolTip(listBox1, null);
   else
       toolTip1.SetToolTip(listBox1, "Item" +
                           listBox1.Items.IndexOf(HotItem));
}
///

Signature

Mick Doherty
http://dotnetrix.co.uk/nothing.html

Sholto Douglas - 28 Feb 2005 01:45 GMT
Hi Mick,
Yes, that is basically the code I used (except I used
listBox.IndexFromPoint(e.X,e.Y) instead of a for() loop to get the index of
the line under the mouse cursor).

> So it's not the tabcontrols tooltip, but a control on the tabpage that is
> showing the error.

No the tooltip belongs to the tab page, but it's not the built-in one that
displays the name of the tab page when you put the mouse over the tab (i.e
the TabPage's ToolTipText property).  There are two controls on that page,
and both lose their tooltip after I click anywhere, even inside that tab page.
Was your example listbox inside a tab control?  As I said, it works fine for
all other tab pages.  I know it sounds like a cop-out, but I am starting to
suspect it's a .NET problem.
Incidentally are you the Mick Doherty of Lemmy fame?

Cheers,
Sholto

> So it's not the tabcontrols tooltip, but a control on the tabpage that is
> showing the error.
[quoted text clipped - 17 lines]
> }
> ///
Mick Doherty - 28 Feb 2005 10:07 GMT
I missed that IndexFromPoint() method, but modifying the code to use that
instead results in the same correct behaviour.
Yes, the listbox is a child of tabPage1, and it makes no difference what I
select when I come back to tabPage1 and move the mouse over the listBox, or
any other control on the tabpage, the Tooltip updates and displays as
expected.

In my case the Tooltip was a component of the form and not of the tabPage,
however, I  just created a TabPage with a built in ToolTip Component and
used that instead. The tooltip still displays as expected.

No I'm not that Mick Doherty.

Signature

Mick Doherty
http://dotnetrix.co.uk/nothing.html

> Hi Mick,
> Yes, that is basically the code I used (except I used
[quoted text clipped - 19 lines]
> Cheers,
> Sholto
Sholto Douglas - 25 Feb 2005 02:15 GMT
> How are you setting the tooltiptext?

   toolTip.SetToolTip(listBox,sTooltip);
where listBox is the control over which it is hovering, and sTooltip is the
string to be displayed

> Have you added your own tooltip class to your custom tabpage or are you
> using the built in tooltip?

I have added my own tooltip because the contents of the tooltip change
according to the line the cursor is hovering over.  I cannot set it at design
time for this reason.  As I said, it works fine for all tab pages except the
'top' one.

> How are you setting the tooltiptext?
> Have you added your own tooltip class to your custom tabpage or are you
> using the built in tooltip?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.