首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >获取ToolTip名称

获取ToolTip名称
EN

Stack Overflow用户
提问于 2013-04-11 17:28:34
回答 1查看 41关注 0票数 1

我一定很愚蠢,但是

代码语言:javascript
复制
    ToolTip tooltip = new ToolTip();
    // tooltip.Name << not exists, lol

我需要它来做这样的事情:

代码语言:javascript
复制
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"
    }
}

我做什么好?Designer以某种方式展示了ToolTip.Name。多么?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-04-26 14:51:26

使用Tag或任何其他自定义属性似乎是实现此目标的唯一解决方案。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15945253

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档