【发布时间】:2010-11-07 00:55:54
【问题描述】:
我希望能够从标准的 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 的帖子 here 双击单选按钮的能力(如果这些是对话框上的 only 控件)使对话框只是一个对于了解它的人来说,使用起来稍微容易一些。
在 Vista 中使用任务对话框(请参阅 this Microsoft guideline page 或 this MSDN page specifically about the Task Dialog API)是显而易见的解决方案,但我们没有这种奢侈。
【问题讨论】:
标签: .net winforms radio-button double-click