1

How can I show Tooltip text on my own TabPages extends from TabPages just added some extra variables and using DrawItem event.

I've generate them in method.

ISIMtabPage newTab = new ISIMtabPage();

// setting up newTab
string contactName = getContactName(object);

chatFormTabs.TabPages.Add(newTab);

toolTip1.SetToolTip((ISIMtabPage)chatFormTabs.TabPages[chatId], contactName);

But if I hover on the tab it doesn't do anything.

I've TabControl.ShowToolTips enabled.

What should I do?

Thanks in advance.

sczdavos
  • 2,035
  • 11
  • 37
  • 71

2 Answers2

1

I would check toolTip1.SetToolTip

example for Tooltip use:

using System.Drawing;
using System.Windows.Forms;

public class Form1 : Form
{
    private TabControl tabControl1;
    private TabPage tabPage1;
    private TabPage tabPage2;

    private void MyTabs()
    {
        this.tabControl1 = new TabControl();
        this.tabPage1 = new TabPage();
        this.tabPage2 = new TabPage();

        this.tabControl1.Controls.AddRange(new Control[] {
            this.tabPage1,
            this.tabPage2});
        this.tabControl1.Location = new Point(35, 25);
        this.tabControl1.Size = new Size(220, 220);

        // Shows ToolTipText when the mouse passes over tabs. 
        this.tabControl1.ShowToolTips = true;

        // Assigns string values to ToolTipText. 
        this.tabPage1.ToolTipText = "myTabPage1";
        this.tabPage2.ToolTipText = "myTabPage2";

        this.Size = new Size(300, 300);
        this.Controls.AddRange(new Control[] {
            this.tabControl1});
    }

    public Form1()
    {
        MyTabs();
    }

    static void Main() 
    {
        Application.Run(new Form1());
    }
}
Lars
  • 947
  • 8
  • 15
  • I see. Then whats the difference between `control.ToolTipText` and `toolTip1.SetToolTip(control, text)` If I can use that control property without using `toolTip` control? – sczdavos Aug 28 '12 at 07:44
  • maybe your tooltip is out of scope? you can also look [here](http://stackoverflow.com/questions/1339524/c-how-do-i-add-a-tooltip-to-a-control) – Lars Aug 28 '12 at 08:44
  • or [here](http://stackoverflow.com/questions/1732140/c-problem-displaying-tooltip-over-a-disabled-control) – Lars Aug 28 '12 at 09:10
1

Actually kinda tricky, so make sure that from the tabControl1 properties "ShowToolTips" is True.

  1. the form1 has a tooltip1 and a TabControl named tabControl1 with multiple tabs for testing

  2. tabControl1 has a collection of tabs

  3. edit the collection and set the tab you want to have the tooltip "ToolTip on toolTip" and ToolTipText to "your message here"

dcarl661
  • 177
  • 3
  • 9