Click here to Skip to main content
15,895,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all

I have a tab control with ShowToolTips = true.
It works fine for static tool tips that I assigned to the tabs using ToolTipText property.
Now I need to make the tool tips dynamic, i.e. change the tip's text before showing it, depending on the tab contents. So, I'd like to use something like MouseHover event to check which tab I am in and change the corresponding ToolTipText. Unfortunately, TabControl.MouseHover event does not tell me which tab the mouse hovers on.

Is there any other event/property I can use?

Thank you
Posted
Comments
Ravi Bhavnani 6-Jan-14 12:49pm    
Shouldn't you be checking the event on a TabPage (and not TabControl)? TabPage is a Control and handles MouseHover.

/ravi

1 solution

TabControl supports selectedIndexChaged event. You can try this:

C#
private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
{
    if (tabControl1.SelectedTab == tabPage1)
        toolTip1.SetToolTip(tabControl1, "TabPage1");
    else if (tabControl1.SelectedTab == tabPage1)
        toolTip1.SetToolTip(tabControl1, "TabPage2");
}



But perhaps you shoud consider to assign tooltip value for each individual tab page. This way you don't need to do any coding.
 
Share this answer
 
Comments
Member 10506786 6-Jan-14 14:00pm    
I need to change the tool tip text while mouse is hovering above the tabs, without changing selected tab - the same way as static tips are shown
Adam Zgagacz 6-Jan-14 14:10pm    
Now I understand. This is tough with .NET build-in tab control. However there are several tab controls you can find in CP. Below are just two examles (there are more). You can download one of them you like most and extend functionality to support your need.

http://www.codeproject.com/Articles/12538/Y-et-A-nother-TabControl-A-Custom-Tab-Control-With
http://www.codeproject.com/Articles/12185/A-NET-Flat-TabControl-CustomDraw
Member 10506786 6-Jan-14 14:12pm    
got the answer from Microsoft C# forum:
http://social.msdn.microsoft.com/Forums/vstudio/en-US/1b9cb025-1f6f-468c-8402-29e1c9f8e1ab/dynamic-tool-tips-for-tab-control?forum=csharpgeneral
Adam Zgagacz 6-Jan-14 14:18pm    
Nice solution. Congratulations!
Adam Zgagacz 6-Jan-14 15:02pm    
Btw, you should take your post out of unanswered questions. Othwerwise peple will be hitting your post while you already know the answer.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900