By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,623 Members | 1,945 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,623 IT Pros & Developers. It's quick & easy.

tooltip for tabcontrol headers?

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.