如何在Form上获取所有工具提示控件 [英] How to get all tooltip controls on Form
本文介绍了如何在Form上获取所有工具提示控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨。
如何收集表格上使用的所有工具提示对象。
我想要的内容如下: -
Hi.
how can i collect all tooltip objects used on form.
I want something like as follows:-
foreach (Control c in this.Controls)
{
if (c is ToolTip)
{
//do something with tooltip control
}
}
但它不起作用......
But its not working...
推荐答案
工具提示是一个组件;它们不会添加到Form的ControlsCollection,也不会添加到Form的Designer.cs文件中的Form Controls的ControlsCollection中。
您可以构建它们像这样的工具提示的集合:
ToolTips are a Component; they are not "added" to a Form's ControlsCollection, or to Container Controls' ControlsCollection in a Form, in the Designer.cs file of a Form.
You can build a collection of ToolTips like this:
public List<ToolTip> tTipList = new List<ToolTip>();
// in some method, or EventHandler like Form_Load
// requires Linq, and Collections.Generic:
tTipList = this.components.Components.OfType<tooltip>().ToList();</tooltip>
相当奇怪的语法,imho。
Rather weird syntax, imho.
这篇关于如何在Form上获取所有工具提示控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文