2013-04-11 51 views
1

我一定是愚蠢的,但獲取工具提示名稱

ToolTip tooltip = new ToolTip(); 
    // tooltip.Name << not exists, lol 

我需要的是這樣的:

public partial class MyForm : Form 
{ 
    private void InitializeComponent() 
    { 
     ... 
     this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); 
     this.toolTip2 = new System.Windows.Forms.ToolTip(this.components); 
     ... 
    } 

    private void SomeMethodOfForm() 
    { 
     SomeMethodOfClassA(components); 
    } 
} 

public class A 
{ 
    public static SomeMethodOfClassA(IContainer container) 
    { 
     foreach (Component component in container.Components) 
      if (component is ToolTip) 
       MessageBox.Show("Found ToolTip"); // want to show here "toolTip1" or "toolTip2" 
    } 
} 

我該怎麼辦?設計師以某種方式顯示ToolTip.Name。怎麼樣?

+0

我可以使用'標籤',但kek .. – Sinatr 2013-04-11 09:58:21

+0

你想完成什麼,你意識到每個工具提示控件可以包含多個控件的工具提示? – 2013-04-26 07:07:09

+0

是的,但我想獲得它的名字,因爲可以有幾十個工具提示(以多種形式,甚至以相同的形式!)。 – Sinatr 2013-04-26 12:23:27

回答

0

使用Tag或任何其他自定義屬性似乎是實現此目的的唯一解決方案。

相關問題