![](/img/trans.png)
[英]Why does Windows Forms databinding want to set my nested boolean databound property when I raise a notification event on the parent object?
[英]Windows forms ToolTip property “ShowAlways” not working when parent object is disabled
根据 Microsoft 开发人员文档,有一个名为ShowAlways的 ToolTip 属性,根据文档;
使用 ShowAlways 属性,即使工具提示的容器未激活,您也可以显示工具提示 window。 您可以在无模式 window 应用程序中使用此功能,以启用工具提示 windows 来显示,无论哪个无模式 window 处于活动状态。
使用下面的示例代码,我无法完成这项工作。
$Form = New-Object system.Windows.Forms.Form
$Form.ClientSize = '200,100'
$Form.text = "test"
$Form.TopMost = $false
$Form.FormBorderStyle = 'FixedDialog'
$Form.MaximizeBox = $false
$Form.StartPosition = 'CenterScreen'
$checkbox1 = New-Object system.Windows.Forms.CheckBox
$checkbox1.text = "Test"
$checkbox1.AutoSize = $true
$checkbox1.width = 100
$checkbox1.height = 20
$checkbox1.location = New-Object System.Drawing.Point(10,50)
$checkbox1.Font = 'Verdana,7'
#Disable checkbox enabled state
$checkbox1.Enabled = $false
$tooltip1 = New-Object System.Windows.Forms.ToolTip
#Showalways property to true
$tooltip1.ShowAlways = $true
$tooltip1.SetToolTip($checkbox1,"This is a tooltip.")
$Form.controls.AddRange($checkbox1)
$Form.ShowDialog()
我错过了什么吗?
I ended up removing the text from the checkbox and replaced it with a label instead so that I can use the ToolTip on that, and added an OnClick action to the label for QoL if the checkbox state is enabled.
也许它不是最好和最漂亮的解决方案,但它是一个可以工作并完成工作的解决方案,直到(或如果)禁用的复选框将来支持工具提示。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.