【发布时间】:2012-06-25 14:57:44
【问题描述】:
我正在尝试将工具提示应用于工具条按钮,但它一直给我这个错误:
Operator '==' cannot be applied to operands of type 'System.Windows.Forms.Control' and 'System.Windows.Forms.ToolStripButton'
关于如何解决这个问题的任何线索?
更新:
private void toolTip1_Popup(object sender, PopupEventArgs e)
{
if (e.AssociatedControl == tBtn1)
{
using (Font f = new Font("Tahoma", 9))
{
e.ToolTipSize = TextRenderer.MeasureText(
toolTip1.GetToolTip(e.AssociatedControl), f);
}
}
}
【问题讨论】:
-
你能添加引发异常的代码吗?
-
您在什么情况下收到此错误。发布给您带来问题的代码...
-
只需将控件转换为它的类型,即工具条按钮
-
按照@nawfal 对
tBtn1的建议,如[..] ==(ToolStripButton)tBtn1[...] -
忽略该评论,我已将其删除。尝试投射
e.AssociatedControl并告诉我们
标签: c# winforms controls tooltip