我希望能够从标准的 winforms 单选按钮捕获 DoubleClick 或 MouseDoubleClick 事件,但它们似乎被隐藏并且不起作用。目前我有这样的代码:
public class RadioButtonWithDoubleClick : RadioButton
{
public RadioButtonWithDoubleClick()
: base()
{
this.SetStyle( ControlStyles.StandardClick | ControlStyles.StandardDoubleClick, true );
}
[EditorBrowsable( EditorBrowsableState.Always ), Browsable( true )]
public new event MouseEventHandler MouseDoubleClick;
protected override void OnMouseDoubleClick( MouseEventArgs e )
{
MouseEventHandler temp = MouseDoubleClick;
if( temp != null ) {
temp( this, e );
}
}
}
有没有更简单、更干净的方法来做到这一点?
编辑:对于背景,我同意 Raymond Chen 在这里的帖子,双击单选按钮(如果这些是对话框上唯一的控件)的能力使对话框对于了解它的人来说更容易使用。
在 Vista 中使用任务对话框(请参阅此 Microsoft 指南页面或此 MSDN 页面专门关于任务对话框 API)将是明显的解决方案,但我们没有这种奢侈。