tags:

views:

38

answers:

1

I have a form with controls and associated tooltips. I'm implementing a help-button witch should show all the tooltips at once.

I would like to implement it somehow like this:

private void btnHelp_Click(object sender, EventArgs e)
{
     System.Windows.Forms.Control.All.Show.Their.Tooltips();
}

Can't find a simple way to do it :-)

I was thinking of using ToolTip.Show() but it requires not only the control, but also the tooltip text - but I don't want to write it again (since necessary tooltips are already assigned in controls' properties).

UPD. I started implementing it with this function:

  public void ShowControlsTooltip(System.Windows.Forms.Control c)
    {
        ttsToolTips.Show(ttsToolTips.GetToolTip(c), c, c.Location.X, c.Location.Y);
    }

But I can't make it show multiple tooltips at the same time.

UPD2. Now I have this kind of code, but all tooltips still blink and disappear.

public void ShowControlsTooltip(System.Windows.Forms.Control c)
{
    ToolTip t = new ToolTip();
    //t = ttsToolTips;
    t.Show(ttsToolTips.GetToolTip(c), c, c.Location.X, c.Location.Y, 1000);
}

private void btnHelp_Click(object sender, EventArgs e)
{
    foreach (Control c in this.Controls)
    {
        try
        {
            ShowControlsTooltip(c);
        }
        catch 
        { 

        }
    }
}

The thing with ttsToolTips is that I have all the tooltips associations there already.

UPD3. it looks like works. But coordinates are not exact.

The big question is now - how to remove all these tooltips at once?

+1  A: 
foreach(Control c in Form.Controls)
{
    string s  = Tooltip.GetTooltip(c);
    c.ShowTooltip(s,this);
}
Michal Franc
good point - i just tried that, but all tooltips blink once and disappear for some reasons. It looks like it's not alowed to have more then one of them at a time?!
Halst
And you want this to look similar to Office when you hit the alt key, correct?
XstreamINsanity
Try creating a different Tooltip object for each control.
Michal Franc