我一定很愚蠢,但是
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"
}
}我做什么好?Designer以某种方式展示了ToolTip.Name。多么?
发布于 2013-04-26 14:51:26
使用Tag或任何其他自定义属性似乎是实现此目标的唯一解决方案。
https://stackoverflow.com/questions/15945253
复制相似问题