简体   繁体   English

在特定条件下如何显示或隐藏工具提示? IWin32window赢了吗?

[英]How to show or hide a tooltip under specific conditions? IWin32window win?

I created a tooltip that's working how expected, the only problem is that sometimes i have to change a option, and i don't want him to show anymore. 我创建了一个按预期工作的工具提示,唯一的问题是有时我不得不更改一个选项,并且我不想他再显示了​​。

I tried 2 things: 我尝试了两件事:

If the conditions wouldn't apply it would reset as 如果条件不适用,它将重置为

toolTip21.Hide(<programname>);

But it would reply a but saying that the programname doesnt exist in the context It was calling for a IWin32window, but since i'm a beginner i don't quite identify all the kinds of data. 但是它会回答一个问题,但是却说程序名在上下文中不存在。它在调用IWin32window,但是由于我是一个初学者,所以我不太了解所有数据类型。 Even in msdn the information is very scarce 即使在msdn中,信息也非常稀缺

https://msdn.microsoft.com/en-us/library/system.windows.forms.iwin32window(v=vs.110).aspx https://msdn.microsoft.com/en-us/library/system.windows.forms.iwin32window(v=vs.110).aspx

interface?? 接口?? why not window?, or Form1, for example? 为什么不开窗口?例如Form1?

I also tried to hide it while in popup, but this was the result 我还试图在弹出窗口时将其隐藏,但这就是结果

在此处输入图片说明

Any hint? 有什么提示吗? I smell noob stuff 我闻到菜鸟味

The issue in your screenshot is that you cannot cast ToolTip to Control as it doesn't derive from it (The ToolTip component is not a control). 屏幕快照中的问题是您无法将ToolTip强制转换为Control,因为它不是源于它(ToolTip组件不是控件)。 However, you could cast the sender to ToolTip directly to use the Hide method, that is: 但是,您可以将发送方直接转换为ToolTip以使用Hide方法,即:

((ToolTip)sender).Hide(someControlWithTooltipBeingShown);

Still, this is probably not the solution you're looking for. 不过,这可能不是您要寻找的解决方案。 If this is the only tooltip associated to you ToolTip component, you could play with its "Active" property and set it to true or false depending on if you want to show tooltips or not. 如果这是与您的ToolTip组件关联的唯一工具提示,则可以使用其“活动”属性,并将其设置为true或false,这取决于是否要显示工具提示。 You could do that when the RadioButton changes. 当RadioButton更改时,您可以这样做。 If this is not your only tooltip, you could create a separate ToolTip component to handle just this tooltip and use the same method above. 如果这不是您唯一的工具提示,则可以创建一个单独的ToolTip组件以仅处理此工具提示,并使用上面的相同方法。 Hope this helps! 希望这可以帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM