473,416 Members | 1,547 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,416 software developers and data experts.

tooltip for tabcontrol headers?

I'm trying to display tooltips when the mouse hovers over the header of
individual tab pages in a tab control, but the tt only displays when the
mouse is over the body of the tab page. Is this by design? What am I doing
wrong?
Nov 20 '05 #1
2 5355
The Tabpage headers are drawn on the tabcontrol and are not part of the
Tabpage, so you need to set the Tooltip of the TabControl and not the
Tabpage.

The following code sample will do as you require, but could do with some
tweaking:

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\\\\\\\\

Private Sub TabControl1_MouseMove(ByVal sender As Object, _
ByVal e As System.Windows.Forms.MouseEventArgs) _
Handles TabControl1.MouseMove
Dim HoverTab As Integer = TestTab(New Point(e.X, e.Y))
If HoverTab >= 0 Then
ToolTip1.SetToolTip(TabControl1, TabControl1.TabPages(HoverTab).Text)
End If
End Sub

Private Function TestTab(ByVal pt As Point) As Integer
Dim returnIndex As Integer = -1
For Each t As TabPage In TabControl1.TabPages
If TabControl1.GetTabRect(t.TabIndex).Contains(pt.X, pt.Y) Then
returnIndex = t.TabIndex
End If
Next
Return returnIndex
End Function

Private Sub TabControl1_MouseLeave(ByVal sender As Object, _
ByVal e As System.EventArgs) _
Handles TabControl1.MouseLeave
ToolTip1.SetToolTip(TabControl1, nothing)
End Sub

////////////////////////////////////////////////////////////////////////

Mick

"Lisa" <sp*********@herplace.com> wrote in message
news:X8********************@eatel.net...
I'm trying to display tooltips when the mouse hovers over the header of
individual tab pages in a tab control, but the tt only displays when the
mouse is over the body of the tab page. Is this by design? What am I doing wrong?

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.683 / Virus Database: 445 - Release Date: 12/05/2004
Nov 20 '05 #2
That did the trick. Thanks so much.

"Mick Doherty"
<EX***********@AND.REMOVE.SQUAREBRACKETS.[mdaudi100#ntlworld.com]> wrote in
message news:ud**************@TK2MSFTNGP09.phx.gbl...
The Tabpage headers are drawn on the tabcontrol and are not part of the
Tabpage, so you need to set the Tooltip of the TabControl and not the
Tabpage.

The following code sample will do as you require, but could do with some
tweaking:

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\\\\\\\\

Private Sub TabControl1_MouseMove(ByVal sender As Object, _
ByVal e As System.Windows.Forms.MouseEventArgs) _
Handles TabControl1.MouseMove
Dim HoverTab As Integer = TestTab(New Point(e.X, e.Y))
If HoverTab >= 0 Then
ToolTip1.SetToolTip(TabControl1, TabControl1.TabPages(HoverTab).Text)
End If
End Sub

Private Function TestTab(ByVal pt As Point) As Integer
Dim returnIndex As Integer = -1
For Each t As TabPage In TabControl1.TabPages
If TabControl1.GetTabRect(t.TabIndex).Contains(pt.X, pt.Y) Then
returnIndex = t.TabIndex
End If
Next
Return returnIndex
End Function

Private Sub TabControl1_MouseLeave(ByVal sender As Object, _
ByVal e As System.EventArgs) _
Handles TabControl1.MouseLeave
ToolTip1.SetToolTip(TabControl1, nothing)
End Sub

////////////////////////////////////////////////////////////////////////

Mick

"Lisa" <sp*********@herplace.com> wrote in message
news:X8********************@eatel.net...
I'm trying to display tooltips when the mouse hovers over the header of
individual tab pages in a tab control, but the tt only displays when the
mouse is over the body of the tab page. Is this by design? What am I

doing
wrong?

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.683 / Virus Database: 445 - Release Date: 12/05/2004

Nov 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Benne | last post by:
Hi, Does anybody know if it's possible to have the small "x" on the tabpages in a tabcontrol ? I need a nice way to close them, without a big, ugly buttom on the tabpage itself. It would be cool...
10
by: VJ | last post by:
Is there any way I can get the rectangle area of the TabPage area only of a TabControl. I am trying here to paint my tabpage area with one color and tabPage tabs in a different color. Thanks...
1
by: Nathan Williams via .NET 247 | last post by:
I'd like to be able to capture a Right Mouse Click event on aparticular Tab and popup a context menu to allow the user toclose the tab without the tab having to be the current selectedtab. Does...
4
by: Oenone | last post by:
I'm using a TabControl to facilitate a wizard-style form, using some of the techniques described here: http://www.codeproject.com/cs/miscctrl/WizardTab.asp For the most part I have this...
4
by: Maileen | last post by:
Hi, Few weeks ago, i asked how to do a tabpage where we don't see the button on the top... in fact, i needed only to show the tabpages without showing the tabpage button (for design purpose) ...
1
by: Hardy Wang | last post by:
Hi all, I have a TabControl in my WinForm, I programmatically all tabs to this control, and add some other controls to each tab. I would also like to set a context menu to each tab, BUT what I...
2
by: Steve | last post by:
Hi All How can I tell how many Windows forms Tabcontrol tabpage headers are visible at any time within a Tabcontrol? I want to display some buttons which offer horizontal scrolling of the...
4
by: Steve | last post by:
Hi All Is there any way to change the colour of the Tabcontrol Tab header strip I have found how to override the individual Tab header colours in the drawitem event but the rest of the...
1
by: \(O\)enone | last post by:
I've added a TabControl to my WinForms app, and added a couple of tabs to the control. The result is that the top strip of the TabControl contains the two tabs, and then to the right of them is...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.