473,385 Members | 1,528 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,385 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 5352
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.